From: Matt Thompson
Subject: convert a list into a function
Date: 
Message-ID: <71f3b43a.0112151115.e9a883f@posting.google.com>
What I would like to do is create a function from a list, I have tried
the following code:

((lambda (x y z) ((lambda (x) y)z)) x x 2)

which would make a function that returns its input (the identity
function), which is 2 in this case. And the compiler doesn't like it.
Can anyone help here?
Thanks,
Matt

From: Barry Margolin
Subject: Re: convert a list into a function
Date: 
Message-ID: <8qaU7.39$TZ5.155872@burlma1-snr2>
In article <···························@posting.google.com>,
Matt Thompson <······@bath.ac.uk> wrote:
>What I would like to do is create a function from a list, I have tried
>the following code:
>
>((lambda (x y z) ((lambda (x) y) z)) x x 2)
>
>which would make a function that returns its input (the identity
>function), which is 2 in this case. And the compiler doesn't like it.
>Can anyone help here?

You're calling the outer lambda expression with X in the parameter list,
but you've probably never assigned that variable.

I've translated your code to the more common LET syntax:

(let ((x x)
      (y x)
      (z 2))
  (let ((x z))
    y))

Now it should be more obvious that there's something wrong with the way you
initialize X and Y, using the uninitialized X.

The other strange thing about your functions is that you never actually use
the variable X.  And the only thing you use Z for is to bind the inner X,
but then you never use that, either.

-- 
Barry Margolin, ······@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: lin8080
Subject: Re: convert a list into a function
Date: 
Message-ID: <3C2EDE87.A3436B53@freenet.de>
Matt Thompson schrieb:
> 
> What I would like to do is create a function from a list, I have tried
> the following code:
> 
> ((lambda (x y z) ((lambda (x) y)z)) x x 2)
> 
> which would make a function that returns its input (the identity
> function), which is 2 in this case. And the compiler doesn't like it.
> Can anyone help here?
> Thanks,
> Matt

; build a list - maybe out of an array?
(setq aa (list (quote setq) (quote a) '(+ 8 9)))
; this is same as: (setq a (+ 8 9))
aa
; should print 17

bye
stefan
From: Coby Beck
Subject: Re: convert a list into a function
Date: 
Message-ID: <vHRX7.226417$Ga5.41403561@typhoon.tampabay.rr.com>
"lin8080" <·······@freenet.de> wrote in message
······················@freenet.de...
> ; build a list - maybe out of an array?
> (setq aa (list (quote setq) (quote a) '(+ 8 9)))
> ; this is same as: (setq a (+ 8 9))
> aa
> ; should print 17
>

will return (setq a (+ 8 9))
You would have to (eval aa) to get 17

--
Coby
(remove #\space "coby . beck @ opentechgroup . com")
From: lin8080
Subject: Re: convert a list into a function
Date: 
Message-ID: <3C305193.EA45A3C3@freenet.de>
Coby Beck schrieb:

> "lin8080" <·······@freenet.de> wrote in message
> ······················@freenet.de...
> > ; build a list - maybe out of an array?
> > (setq aa (list (quote setq) (quote a) '(+ 8 9)))
> > ; this is same as: (setq a (+ 8 9))
> > aa
> > ; should print 17

> will return (setq a (+ 8 9))
> You would have to (eval aa) to get 17

Yes. I forgot it. 
I used this method in a fuzzy like test programm. It takes long case
lists but with CL it is very fast :)

bye
stefan