guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Parameters


From: Sebastian Tennant
Subject: Parameters
Date: Mon, 04 Feb 2008 15:51:49 +0200
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1 (gnu/linux)

Hi list,

No doubt something of a newbie question this...

This simple procedure behaves as expected, i.e., it provides the sum of
a list of numbers:

 (define add
   (lambda (l)
     (if (null? l)
         0
       (+ (add (cdr l)) (car l)))))

whereas this procedure results in a stack overflow:

 (define add
   (lambda l
     (if (null? l)
         0
       (+ (add (cdr l)) (car l)))))

the only difference being the designation of the formal parameter of the
anonymous procedure; l or (l).

Why is this?

Regards,

Sebastian





reply via email to

[Prev in Thread] Current Thread [Next in Thread]