From: tebeka michael
Subject: Function returning lambda experssion
Date: 
Message-ID: <5puf8i$k5q@news.huji.ac.il>
Hello All.

Can anyone tell me how to write a function that returns a lambda
experssion?

I've tried:
(defun x() #'(lambda (y) (+ y 1)))
and then
((x) 5)
got me nowhere.

Thanks.


--
     O O      Smile, damn it, smile.
    \___/    
                      Miki
               ······@cs.bgu.ac.il	
         http://www.cs.bgu.ac.il/~tebeka

-- Ambition is a poor excuse for not having enough sense to be lazy --



      

From: Laurent Arditi
Subject: Re: Function returning lambda experssion
Date: 
Message-ID: <33C2DC12.4368EC8@shallot.stanford.edu>
x is OK, your call is not.
(funcall x 5) works.

tebeka michael wrote:
> 
> Hello All.
> 
> Can anyone tell me how to write a function that returns a lambda
> experssion?
> 
> I've tried:
> (defun x() #'(lambda (y) (+ y 1)))
> and then
> ((x) 5)
> got me nowhere.
> 
> Thanks.
> 
> --
>      O O      Smile, damn it, smile.
>     \___/
>                       Miki
>                ······@cs.bgu.ac.il
>          http://www.cs.bgu.ac.il/~tebeka
> 
> -- Ambition is a poor excuse for not having enough sense to be lazy --
> 
> 

-- 
****************************************************************************
Laurent Arditi. Stanford University, Computer Systems Lab          
/\/\/\/|
    ······@sprout.stanford.edu       
http://sprout.stanford.edu/arditi    |
*************** "AY CARUMBA !": Bart's first words
*****************|      |
From: Simon Leinen
Subject: Re: Function returning lambda experssion
Date: 
Message-ID: <aawwn0vg3m.fsf@babar.switch.ch>
Laurent Arditi <······@shallot.stanford.edu> writes:

> x is OK, your call is not.
> (funcall x 5) works.

Have you actually tried this?
It should have been

  (funcall (x) 5)
-- 
Simon.
From: Thomas A. Russ
Subject: Re: Function returning lambda experssion
Date: 
Message-ID: <ymilo3gxpwp.fsf@sevak.isi.edu>
In article <··········@news.huji.ac.il> ······@black (tebeka michael) writes:


 > Can anyone tell me how to write a function that returns a lambda
 > experssion?
 > 
 > I've tried:
 > (defun x() #'(lambda (y) (+ y 1)))

This is correct.  The function X returns a function object (closure).

 > and then
 > ((x) 5)

This would work in Scheme, but not in Common Lisp or similar lisps.  In
CL, the function position is not evaluated, but rather has its function
value used.  You need to use FUNCALL to apply the returned function:


(funcall (x) 5)

-- 
Thomas A. Russ,  USC/Information Sciences Institute          ···@isi.edu