Re: [Haskell-cafe] list -> sublists

2009-10-21 Thread Eduard Sergeev
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 [[]] where st x xss | x == n = [x]:xss st x (xs:xss) = (x:x

Re: [Haskell-cafe] list -> sublists

2009-10-20 Thread Richard O'Keefe
On Oct 21, 2009, at 3:16 AM, satorisanitarium wrote: I just started learning haskell and I just came to my first wtf moment. I'm trying to do something like this: calling: foo 3 [1,2,3,2,4,1,6,3,6,2,3,5,2,5,2,1,6,4] returns: [[1,2,3],[2,4,1,6,3],[2,3]] but i have no idea how to put some

Re: [Haskell-cafe] list -> sublists

2009-10-20 Thread Ariel J. Birnbaum
> Now back to your original problem. Can you write a function g such that > g [1,2,3,2,4,1,6,3,6,2,3,5,2,5,2,1,6,4] > returns > ([1,2,3],[2,4,1,6,3,6,2,3,5,2,5,2,1,6,4]) > > g [2,4,1,6,3,6,2,3,5,2,5,2,1,6,4] > returns: > ([2,4,1,6,3],[6,2,3,5,2,5,2,1,6,4]) > > and so on ? Then you should be able

Re: [Haskell-cafe] list -> sublists

2009-10-20 Thread minh thu
2009/10/20 satorisanitarium : > > I just started learning haskell and I just came to my first wtf moment. > > I'm trying to do something like this: > > calling: > foo 3 [1,2,3,2,4,1,6,3,6,2,3,5,2,5,2,1,6,4] > > returns: > [[1,2,3],[2,4,1,6,3],[2,3]] > > but i have no idea how to put something into

[Haskell-cafe] list -> sublists

2009-10-20 Thread satorisanitarium
I just started learning haskell and I just came to my first wtf moment. I'm trying to do something like this: calling: foo 3 [1,2,3,2,4,1,6,3,6,2,3,5,2,5,2,1,6,4] returns: [[1,2,3],[2,4,1,6,3],[2,3]] but i have no idea how to put something into a sublist. How to make a list of sublists out of