[Haskell-beginners] Re: Defining 'words' in terms of 'span'

Roger Whittaker roger at disruptive.org.uk
Wed Mar 17 14:03:47 EDT 2010


On Wed, Mar 17, 2010 at 10:10:27AM +0100, Heinrich Apfelmus wrote:

> Then, you can group the four different cases, noting that they are
> actually independent of each other: the result is always a concatenation
> of either  []  or  [l]  with either  []  or  mywords (tail r)
> 
>     mywords xs = y ++ ys
>         where
>         (l,r) = span isAlpha xs
>         y     = if l == "" then [] else [l]
>         ys    = if r == "" then [] else mywords (tail r)

That's a great help - thank you.


-- 
========================
Roger Whittaker
roger at disruptive.org.uk
http://disruptive.org.uk
========================


More information about the Beginners mailing list