Ticket #4157 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

A bug of dropWhileR in Data.Sequence

Reported by: kazu-yamamoto Owned by: igloo
Priority: normal Milestone:
Component: libraries (other) Version: 6.12.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description (last modified by igloo) (diff)

The document of dropWhileR says: dropWhileR p xs is equivalent to reverse (dropWhileL p (reverse xs)).

However,

reverse $ dropWhileL (==4) $ reverse $ fromList [1,2,3,4]
==> fromList [1,2,3]

dropWhileR (==4) $ fromList [1,2,3,4]
==> fromList [1,2]

I guess the cause of bug is in breakl.

Original:

breakl p xs = foldr (\ i _ -> S.splitAt i xs) (xs, empty) (findIndicesL p xs)

Fixed:

breakl p xs = foldr (\ i _ -> S.splitAt (i+1) xs) (xs, empty) (findIndicesL p xs)

Change History

Changed 3 years ago by igloo

  • description modified (diff)

Changed 3 years ago by igloo

  • owner set to igloo

Changed 3 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

Thanks for the report; fixed:

Sun Jul  4 07:06:27 PDT 2010  Ian Lynagh <igloo@earth.li>
  * Fix Data.Sequence's breakr, and add a test for it; fixes trac #4157
Note: See TracTickets for help on using tickets.