Re: [Haskell-cafe] mapAccumL - find max in-sequence subsequence

2006-10-30 Thread Ross Paterson
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

Re: [Haskell-cafe] mapAccumL - find max in-sequence subsequence

2006-10-29 Thread jim burton
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

Re: [Haskell-cafe] mapAccumL - find max in-sequence subsequence

2006-10-28 Thread Sebastian Sylvan
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

[Haskell-cafe] mapAccumL - find max in-sequence subsequence

2006-10-28 Thread jim burton
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