Loops ==> Recursion
words xs =
let noSpace = dropWhile isSpace xs in
if null noSpace then [] else
let (word, rest) = break isSpace noSpace in
word : words rest
Recursive call to find words
in the rest of the list.
`Cons´ adds an element at
the beginning of a list.
1 : [2, 3] [1, 2, 3]
Föregående bild
Nästa bild
Tillbaka till första bilden
Visa grafisk version