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

Roger Whittaker roger at disruptive.org.uk
Tue Mar 16 13:08:15 EDT 2010

I found some exam papers linked from this page:

And I have been trying some questions from them.  

I'm currently baffled by question 2(b) on this one:

  A word is a sequence of alphabetic characters, which you can recognise
  using the standard function

  isAlpha :: Char -> Bool

  Using span, define a function words :: String -> [String] which
  finds a list of the words occurring in a string. For example,

  words "Now is the winter of our discontent!"
    == ["Now","is","the","winter","of","our","discontent"]

  words "2+3" == []

  words "1 by 1" == ["by"]

Can anyone give me a clue how to start?

Roger Whittaker
roger at disruptive.org.uk

More information about the Beginners mailing list