[Haskell-cafe] list -> sublists

Eduard Sergeev Eduard.Sergeev at gmail.com
Wed Oct 21 15:25:47 EDT 2009

satorisanitarium wrote:
> How to make a list of sublists out of a list, whether they be a list of
> numbers or a string.

Without recursion (with fold) starting from the tail of the input list:

foo n = foldr st [[]]
        st x xss | x == n = [x]:xss
        st x (xs:xss) = (x:xs):xss 
View this message in context: http://www.nabble.com/list--%3E-sublists-tp25975341p25998649.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

More information about the Haskell-Cafe mailing list