<div><div dir="auto">Made some changes to replaceThe to handle the possibility of empty list:</div><div dir="auto"><br></div><div dir="auto">replaceThe :: String -> String</div><div dir="auto">replaceThe word = go $ words word</div><div dir="auto">   where </div><div dir="auto">      go [] = “”</div><div dir="auto">      go (x:xs) =</div><div dir="auto">         case (notThe x) of</div><div dir="auto">            Just x -> x ++ “ “ ++ go xs</div></div><div dir="auto">            Nothing -> “ a “ ++ go xs</div><div dir="auto"><br></div><div dir="auto">Typed this on a phone, sorry </div><div><div><br><div class="gmail_quote"><div>On Sat, Nov 18, 2017 at 09:16 Jim <<a href="mailto:jimbo4350@gmail.com" target="_blank">jimbo4350@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hey guys,<br>
<br>
Thiis is my function below:<br>
<br>
notThe :: String -> Maybe String<br>
notThe word<br>
       | word /= "the" = Just word<br>
       | word == [] = Just []<br>
       | otherwise = Nothing<br>
<br>
replaceThe :: String -> String<br>
replaceThe word = go (words word)<br>
       where go (x:xs)<br>
               | notThe x == Just [] = []<br>
               | notThe x == Just word = word ++ go xs<br>
               | notThe word == Nothing = " a " ++ go xs<br>
<br>
<br>
 > replaceThe "what"<br>
"what*** Exception: chap12.hs:(13,13)-(16,55): Non-exhaustive patterns<br>
in function go<br>
<br>
I thought I covered all the potential patterns in my replaceThe<br>
function. I'm not sure what pattern I've missed, any thoughts?<br>
<br>
Best regards,<br>
<br>
Jim<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote></div></div></div>