<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Feb 20, 2015 at 1:32 AM, Roelof Wobben <span dir="ltr"><<a href="mailto:r.wobben@home.nl" target="_blank">r.wobben@home.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
Im try to the solve the exercise which does the following :<br>
<br>
"E 2 562 help he<br>
<br>
and convert it into<br>
<br>
(Error 2) 562 "help help<br>
<br>
First I thought to split the string on the " " but according to google Haskell do not have a split function.<br>
<br>
Can I use pattern matching on some way ?<br></blockquote><div><br></div><div>You can do pattern matching on lists, and strings are lists of chars, so you can always do it that way.</div><div><br></div><div>I'm not sure what you mean by "Haskell do not have a split function". It may not have one by that name, but it has a bunch of functions for splitting up lists and strings. If you want a list of words, then words will give it to you. If you want to split it into two halves, then either span or break will do that for you. Neither discards the dividing character, since they take a predicate to determine the split rather than a value, which means the dividing character may not be obvious after the split. It's common to find that where procedural languages take a value to test against, functional ones take a predicate that does the test, as it's trivial to create a predicate to test for equality with a specific value.</div><div><br></div><div>You might also want to look through Data.Char for interesting predicates (like isSpace) to use with those functions.</div></div></div></div>