[Haskell-cafe] returning lists
sebastian.sylvan at gmail.com
Thu Dec 1 14:54:04 EST 2005
On 12/1/05, raptor <raptor at tvskat.net> wrote:
> i'm having this problem, tring to implement split (for learning purposes).
> Here is one sample of my tries :
> split _  = 
> split char (x:xs)
> | x /= char = x : split char xs
> | otherwise = 
> it is ok i.e. it returns the first of the splits, but I want to get
> all of the results.
> str = "testingxsplitxtoxseexhowxitxwork"
> *Main> split 'x' str
> I want :
> How do i do this.
A good start is to write a function which returns the first split, as
well as the remainder of the string as a tuple.
Then you can use this function over and over on the remainder of each
call until it is "".
More information about the Haskell-Cafe