Skip to content

Commit bac422e

Browse files
committed
Fix Stream.deleteFirstsBy
1 parent c54929d commit bac422e

File tree

1 file changed

+3
-3
lines changed
  • core/src/Streamly/Internal/Data/Stream

1 file changed

+3
-3
lines changed

core/src/Streamly/Internal/Data/Stream/Top.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ sortedIntersectBy cmp (Stream stepa ta) (Stream stepb tb) =
334334
--
335335
-- >>> f xs ys = Stream.fold Fold.toList $ Stream.deleteFirstsBy (==) (Stream.fromList xs) (Stream.fromList ys)
336336
-- >>> f [1,2,2,3,3,5] [1,2,2,3,4]
337-
-- [2,3,5]
337+
-- [3,5]
338338
--
339339
-- The following holds:
340340
--
@@ -365,9 +365,9 @@ deleteFirstsBy eq s2 s1 =
365365
-- It reverses the list but that is fine.
366366
let del x =
367367
List.foldl' (\(ys,res) y ->
368-
if x `eq` y
368+
if not res && x `eq` y
369369
then (ys, True)
370-
else (x:ys, res)) ([], False)
370+
else (y:ys, res)) ([], False)
371371
g (ys,_) x =
372372
let (ys1, deleted) = del x ys
373373
in if deleted

0 commit comments

Comments
 (0)