We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8501802 commit fa18006Copy full SHA for fa18006
1 file changed
src/Streamly/Coreutils/Cut.hs
@@ -87,16 +87,16 @@ stripLatin1 = Array.dropAround (isSpace . chr. fromIntegral)
87
makeIndexMask :: [Int] -> [Bool]
88
makeIndexMask indices =
89
-- Sort would be O(n) if pre-sorted
90
- let xs1 = List.sort $ filter (>= 0) indices
+ let xs1 = fmap List.head $ List.group $ List.sort $ filter (>= 0) indices
91
in go 0 xs1 id
92
93
where
94
95
go _ [] ys = ys []
96
go i old@(x:xs) ys =
97
if i == x
98
- then go (i + 1) xs ((True :) . ys)
99
- else go (i + 1) old ((False :) . ys)
+ then go (i + 1) xs (ys . (True :))
+ else go (i + 1) old (ys . (False :))
100
101
-- | Zip the input stream with the supplied mask and keep only those elements
102
-- which are True in the mask stream.
0 commit comments