It's a pity that groupBy isn't defined a little differently:
-- @'groupBy' rel xs@ returns the shortest list of lists such that
--
-- * the concatenation of the lists is @xs@, and
--
-- * @rel@ is 'True' for each consecutive pair of elements in a sublist.
--
groupBy :: (a -> a -> B
Sebastian Sylvan-2 wrote:
>
> I'm not sure I completely understand what you want, and if it needs to
> be "cute" (i.e. some clever one liner usage of a library function).
> But here's my "get-the-job-done-solution" (assuming I understood what
> you want):
>
> import Data.List
> import Data.Ord
On 10/28/06, jim burton <[EMAIL PROTECTED]> wrote:
I need to find the length of the longest in-sequence section of a list of
ints...I am guessing something like mapAccumL is the way but not sure how.
--this doesn't work
Prelude List> mapAccumL (\x y -> if y==(x+1) then (y, x) else (y,0)) 0 $
so
I need to find the length of the longest in-sequence section of a list of
ints...I am guessing something like mapAccumL is the way but not sure how.
--this doesn't work
Prelude List> mapAccumL (\x y -> if y==(x+1) then (y, x) else (y,0)) 0 $
sort $ nub [9, 1, 2, 7, 3, 4, 5, 6,5]
(9,[0,1,2,3,4,5