[Haskell-beginners] pattern matching on strings ?

Frerich Raabe raabe at froglogic.com
Fri Feb 20 08:50:10 UTC 2015


On 2015-02-20 08:32, Roelof Wobben wrote:
> Im try to the solve the exercise which does the following :
> 
> "E 2 562 help he
> 
> and convert it into
> 
> (Error 2) 562 "help help
> 
> First I thought to split the string on the " " but according to google 
> Haskell do not have a split function.
> 
> Can I use pattern matching on some way ?

Instead of using Google, I suggest to first think about this in terms of 
types. You're looking for a function which can turn a string into a list of 
strings, i.e.

   String -> [String]

You can feed types like this to Hoogle ( http://www.haskell.org/hoogle ) to 
get function which match that type. Searching for the above type signature 
yields some very relevant hits. :-)

-- 
Frerich Raabe - raabe at froglogic.com
www.froglogic.com - Multi-Platform GUI Testing


More information about the Beginners mailing list