Simple answer: you always have to have the single element first, then the list bit second.&nbsp; It&#39;s just the way it is.&nbsp; You can learn why later on ;-)<br><br><div><span class="gmail_quote">On 7/11/07, <b class="gmail_sendername">
Alexteslin</b> &lt;<a href="mailto:alexteslin@yahoo.co.uk">alexteslin@yahoo.co.uk</a>&gt; 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.&nbsp;&nbsp;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.&nbsp;&nbsp;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>&gt;<br>&gt; Hi<br>&gt;<br>&gt;&gt; unique = unique&#39; []<br>&gt;&gt;<br>&gt;&gt; unique&#39; _ [] = []<br>&gt;&gt; unique&#39; history (x:xs) = if x `elem` history<br>&gt;&gt;&nbsp;&nbsp; then next
<br>&gt;&gt;&nbsp;&nbsp; else (x:next) where next = (uniq&#39; (x:hist) xs)<br>&gt;<br>&gt; You can express this more neatly:<br>&gt;<br>&gt; unique&#39; _ [] = []<br>&gt; unique&#39; history (x:xs) = [x | x `notElem` history] ++ unique&#39; (x:history)
<br>&gt; xs<br>&gt;<br>&gt; Thanks<br>&gt;<br>&gt; Neil<br>&gt; _______________________________________________<br>&gt; Haskell-Cafe mailing list<br>&gt; <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a>
<br>&gt; <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>&gt;<br>&gt;<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>