Lisp-likeness

Thomas A. Russ tar at sevak.isi.edu
Tue Mar 15 17:16:09 EST 2005


Fernando  <frr at easyjob.net> writes:

> 
> On 15 Mar 2005 00:43:49 -0800, "Kay Schluehr" <kay.schluehr at gmx.net>
> wrote:
> 
> >Maybe You can answer my question what this simple LISP function does ?
> >
> >(defun addn (n)
> >	  #'(lambda (x)
> >	      (+ x n)))
> 
> The same as 
> def addn(n):
> 	def fn(x):
> 		return n + x
> 	return fn

Is this really equivalent?

What happens if you call addn more than once with different
parameters.  Will you get different functions that you can
use simultaneously?

The lisp snippet creates new functions each time the addn function is
called, so one can interleave calls to the individual functions.

-- 
Thomas A. Russ,  USC/Information Sciences Institute




More information about the Python-list mailing list