"Recursion is the goto of functional programming". Also, "Do not confuse what is natural with what is habitual." - Conal<br><br><div class="gmail_quote">On Tue, Mar 24, 2009 at 1:51 PM, Manlio Perillo <span dir="ltr"><<a href="mailto:manlio_perillo@libero.it">manlio_perillo@libero.it</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Jake McArthur ha scritto:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
[...]<div class="im"><br>
| With my function, instead, you only have to "follow" 1 operation:<br>
|<br>
| Prelude> (head, tail) = splitAt n xs<br>
<br>
I think you are way oversimplifying your own code.<br>
<br>
~ takeList :: [Int] -> [a] -> [[a]]<br>
~ takeList [] _ = []<br>
~ takeList _ [] = []<br>
~ takeList (n : ns) xs = head : takeList ns tail<br>
~ where (head, tail) = splitAt n xs<br>
<br>
In order to understand this, I have to look at three different cases, an<br>
uncons, a splitAt, a cons, *and* a recursive call. This is *seven*<br>
different things I have to absorb.<br>
</div></blockquote>
<br>
These cases are, IMHO, more "natural".<br>
<br>
We have a set of equations, pattern matching and recursion.<br>
These are one of the basic building block of Haskell.<br>
<br>
The only "foreign" building block is the splitAt function.<br>
<br>
But this may be really a question of personal taste or experience.<br>
What is more "natural"?<br>
<br>
1) pattern matching<br>
2) recursion<br>
or<br>
1) function composition<br>
2) high level functions<br>
<br>
?<br>
<br>
> [...]<br><font color="#888888">
<br>
<br>
Manlio</font><div><div></div><div class="h5"><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>
</div></div></blockquote></div><br>