or, since you don't need to give a name to the second element of the list:<br><br><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">f :: [a] -> [a]</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">f (x:_:xs) = x : f xs</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">f x = x</span><br><br><br><br><div class="gmail_quote">
On 7 June 2010 20:11, Ozgur Akgun <span dir="ltr"><<a href="mailto:ozgurakgun@gmail.com">ozgurakgun@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
i think explicit recursion is quite clean?<br><br><br><span style="font-family: courier new,monospace;">f :: [a] -> [a]</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">f (x:y:zs) = x : f zs</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">f x = x</span><div><div></div><div class="h5"><br style="font-family: courier new,monospace;"><br><br><br><div class="gmail_quote">On 7 June 2010 19:42, Thomas Hartman <span dir="ltr"><<a href="mailto:tphyahoo@gmail.com" target="_blank">tphyahoo@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">maybe this?<br>
<br>
map snd . filter (odd . fst) . zip [1,2..] $ [1,2,3,4,5]<br>
<br>
2010/6/6 R J <<a href="mailto:rj248842@hotmail.com" target="_blank">rj248842@hotmail.com</a>>:<br>
<div><div></div><div>> What's the cleanest definition for a function f :: [a] -> [a] that takes a<br>
> list and returns the same list, with alternate items removed? e.g., f [0,<br>
> 1, 2, 3, 4, 5] = [1,3,5]?<br>
><br>
> ________________________________<br>
> The New Busy is not the old busy. Search, chat and e-mail from your inbox.<br>
> Get started.<br>
</div></div>> _______________________________________________<br>
> Haskell-Cafe mailing list<br>
> <a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
><br>
><br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br><br clear="all"><br></div></div>-- <br><font color="#888888">Ozgur Akgun<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Ozgur Akgun<br>