Simple answer: you always have to have the single element first, then the list bit second. It's just the way it is. You can learn why later on ;-)<br><br><div><span class="gmail_quote">On 7/11/07, <b class="gmail_sendername">
Alexteslin</b> <<a href="mailto:alexteslin@yahoo.co.uk">alexteslin@yahoo.co.uk</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Oh, I am lost now - for now anyway.<br>I am attempting to do next exercise in the book to define reverse function<br>using primitive recursion and pattern matching on lists. But getting stack<br>because when i con in front of xs (xs:x) i get en error, which i thought i
<br>would be getting anyway. I tried to define a helper function and cons there<br>in front of xs and i get type errors again.<br><br>I know these are easy and boring questions but i would appreciate a hint.<br><br>Thank you
<br><br><br>Neil Mitchell wrote:<br>><br>> Hi<br>><br>>> unique = unique' []<br>>><br>>> unique' _ [] = []<br>>> unique' history (x:xs) = if x `elem` history<br>>> then next
<br>>> else (x:next) where next = (uniq' (x:hist) xs)<br>><br>> You can express this more neatly:<br>><br>> unique' _ [] = []<br>> unique' history (x:xs) = [x | x `notElem` history] ++ unique' (x:history)
<br>> xs<br>><br>> Thanks<br>><br>> Neil<br>> _______________________________________________<br>> Haskell-Cafe mailing list<br>> <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a>
<br>> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>><br>><br><br>--<br>View this message in context: <a href="http://www.nabble.com/function-unique-tf4058328.html#a11547781">
http://www.nabble.com/function-unique-tf4058328.html#a11547781</a><br>Sent from the Haskell - Haskell-Cafe mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br><br>_______________________________________________
<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe
</a><br></blockquote></div><br>