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
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.
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
"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")
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