mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-08-27 00:36:02 +08:00
Use list comprehensions instead of clunky combinations of map and filter
This commit is contained in:
@@ -295,7 +295,7 @@ prop_pstreeSumsCorrectly kvs targets =
|
||||
-- Trivial O(n * m) implementation
|
||||
dumbPrefixSums :: [(Int, Int)] -> [Int] -> [Int]
|
||||
dumbPrefixSums kvs targets =
|
||||
let prefixSum target = sum . map snd . filter (\(k,v) -> k <= target) $ kvs
|
||||
let prefixSum target = sum [v | (k,v) <- kvs, k <= target]
|
||||
in map prefixSum targets
|
||||
-- PSTree O(n * log m) implementation
|
||||
smartPrefixSums :: [(Int, Int)] -> [Int] -> [Int]
|
||||
|
Reference in New Issue
Block a user