On 28-Sep-2004, John Goerzen [EMAIL PROTECTED] wrote:
As I'm investigating Haskell, it's occured to me that most of the
Haskell tutorials out there have omitted something that was quite
prominent in the OCaml material I had read: making functions properly
tail-recursive.
The OCaml compiler
Fergus Henderson [EMAIL PROTECTED] held forth:
On 28-Sep-2004, John Goerzen [EMAIL PROTECTED] wrote:
As I'm investigating Haskell, it's occured to me that most of the
Haskell tutorials out there have omitted something that was quite
prominent in the OCaml material I had read: making
Hello,
As I'm investigating Haskell, it's occured to me that most of the
Haskell tutorials out there have omitted something that was quite
prominent in the OCaml material I had read: making functions properly
tail-recursive.
The OCaml compiler was able to optimize tail-recursive functions such
John Goerzen [EMAIL PROTECTED] writes:
The OCaml compiler was able to optimize tail-recursive functions such
that they could be compiled using a loop. This would achieve two main
benefits: performance due to not needing to allocate/deallocate stack
frames, and the ability to work on very
hello,
John Goerzen wrote:
Hello,
As I'm investigating Haskell, it's occured to me that most of the
Haskell tutorials out there have omitted something that was quite
prominent in the OCaml material I had read: making functions properly
tail-recursive.
The OCaml compiler was able to optimize
On Tuesday 28 September 2004 01:54 am, Iavor S. Diatchki wrote:
OTOH there are a few classical cases in haskell where you run out of
space even if you have a tail
recursive function: e.g.
sum n [] = n
sum n (y:ys) = sum (n + y) ys
the reason for this that the n+y expression never gets
John Goerzen [EMAIL PROTECTED] writes:
If I instead wrote:
sum [] = 0
sum (x:xs) = x + sum(xs)
then I have the same problem.
What is the proper way to solve this little problem then?
sum n [] = n
sum n (x:xs) = (sum $! n + x) xs
It's unfortunate that it requires $! or seq, but it's
On Tuesday 28 Sep 2004 8:17 pm, John Goerzen wrote:
On Tuesday 28 September 2004 01:54 am, Iavor S. Diatchki wrote:
OTOH there are a few classical cases in haskell where you run out of
space even if you have a tail
recursive function: e.g.
sum n [] = n
sum n (y:ys) = sum (n + y) ys