[plt-scheme] Fac calculus and memory swapping...
Try running mzscheme in the bin directory. Define the function in
the command line and try again. This might 'rule out' that the
problem is in the calculation.
> (define (fac n)
(if (= n 0)
1
(* n (fac ( - n 1)))))
> (time (fac 5))
cpu time: 0 real time: 0 gc time: 0
120
>
rac
On Nov 6, 2006, at 2:53 AM, Guillaume R. wrote:
> Hello
> I'm quite a newbie in the functionnal world. So I decided to learn
> more on
> recursive algorithms using scheme.
> Here is my problem. I write this piece of code
>
> ;; should calculate n!
> (define (fac n)
> (if (= n 0)
> 1
> (* n (fac ( - n 1)))))
>
> For me this should work. Indeed it doesnt: if I try (fac 5) my
> computer is
> swapping using 92,5% of my memory (!). I tried this snippet on a
> freebsd
> computer with a DrScheme from 8september svn and on a linux box with a
> drscheme 350.
> Same results on both...So is it a memory leak or am I wrong in my
> definition
> of n! ?
> Thx for your help
>
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme