mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-07 21:41:34 -07:00
Use list comprehensions instead of clunky combinations of map and filter
This commit is contained in:
parent
f25b8bd03a
commit
e6e89d68fd
2 changed files with 4 additions and 4 deletions
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue