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
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
> 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
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
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