For Programmers: Free Programming Magazines  


Home > Archive > Scheme > February 2007 > What is the difference between these two expressions?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author What is the difference between these two expressions?
Griff

2007-02-09, 7:10 pm

Hi,

Why does the first function give a and the second gives (a)?

> (let ((f (lambda (x) x))) (f 'a))

a
> (let ((f (lambda x x))) (f 'a))

(a)
>


Nils M Holm

2007-02-09, 7:10 pm

Griff <grettke@gmail.com> wrote:
> Hi,
>
> Why does the first function give a and the second gives (a)?
>
> a
> (a)


What do the following expressions reduce to?

((lambda (x) x))
((lambda (x) x) 'a 'b)

And these?

((lambda x x))
((lambda x x) 'a 'b)

--
Nils M Holm <n m h @ t 3 x . o r g> -- http://t3x.org/nmh/
Jens Axel Søgaard

2007-02-09, 7:10 pm

Griff skrev:
> Hi,
>
> Why does the first function give a and the second gives (a)?
>
> a
> (a)


The syntax of a lambda expression is (lambda <formals> <body> ).
See the explanation of <formals> here:

<http://www.schemers.org/Documents/S...tml#%_sec_4.1.4>

--
Jens Axel Søgaard
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com