On Mon, 2005-12-05 at 23:54 +0100, Jens Axel Søgaard wrote:
> Sunnan wrote:
> > ;; instead of:
> > (let f ((n (...)))
> > (if (zero? n) 1
> > (* n (f (- n 1)))))
> > ;; it's the exact same number of characters!
>
> Almost - note that REC returns the recursive
> function, so you need to return the function
> in the let:
>
> ((let f ((n (...)))
> (if (zero? n) 1
> (* n (f (- n 1))))
> f)
> (...))
But that does the same thing; the whole expression as such returns the
result of the recursive function in both cases. The recursive function
returned by REC is use-once-and-destroy.
And in chicken,
((rec (F N)
(if (zero? N) 1
(* N (F (- N 1))))) (...))
macroexpands to almost the same as
(let f ((n (...)))
(if (zero? n) 1
(* n (f (- n 1)))))
if I recall correctly.
BTW, your example evaluates (...) twice.
AML,
Sunnan
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users