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

jim burton jim at sdf-eu.org
Sat Oct 28 17:45:28 EDT 2006


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,6,0])


-- 
View this message in context: http://www.nabble.com/mapAccumL---find-max-in-sequence-subsequence-tf2531704.html#a7054981
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.



More information about the Haskell-Cafe mailing list