On Wed, Mar 18, 2009 at 12:49 PM, Tom.Amundsen
<tomamundsen@gmail.com> wrote:
Hi All,
I am new to Haskell. I just started reading "Real World Haskell" a few days
ago, so I apologize for being such a noob.
But, I am curious why I see a lot of code where people do pattern matching
via multiple function declarations instead of using the case ... of ...
construct? For example:
[code]
foldl' _ zero [] = zero
foldl' step zero (x:xs) =
let new = step zero x
in new `seq` foldl' step new xs
[/code]
instead of this, which I prefer:
[code]
foldl' f acc xs = case xs of
[] -> acc
(x:xs) -> let new = f acc x
in new `seq` foldl' f new xs
[/code]