[Haskell-cafe] about Haskell code written to be "too smart"
conal at conal.net
Tue Mar 24 16:55:41 EDT 2009
"Recursion is the goto of functional programming". Also, "Do not confuse
what is natural with what is habitual." - Conal
On Tue, Mar 24, 2009 at 1:51 PM, Manlio Perillo <manlio_perillo at libero.it>wrote:
> Jake McArthur ha scritto:
>> | With my function, instead, you only have to "follow" 1 operation:
>> | Prelude> (head, tail) = splitAt n xs
>> I think you are way oversimplifying your own code.
>> ~ takeList :: [Int] -> [a] -> [[a]]
>> ~ takeList  _ = 
>> ~ takeList _  = 
>> ~ takeList (n : ns) xs = head : takeList ns tail
>> ~ where (head, tail) = splitAt n xs
>> In order to understand this, I have to look at three different cases, an
>> uncons, a splitAt, a cons, *and* a recursive call. This is *seven*
>> different things I have to absorb.
> These cases are, IMHO, more "natural".
> We have a set of equations, pattern matching and recursion.
> These are one of the basic building block of Haskell.
> The only "foreign" building block is the splitAt function.
> But this may be really a question of personal taste or experience.
> What is more "natural"?
> 1) pattern matching
> 2) recursion
> 1) function composition
> 2) high level functions
> > [...]
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe