newbie questions: why doesn't ((lambda (x) (x 2)) (lambda (n) (+ n 3))) work in elisp?
  Home FAQ Contact Sign in
gnu.emacs.help only
 
Advanced search
POPULAR GROUPS

more...

gnu.emacs.help Profile…
 Up
newbie questions: why doesn't ((lambda (x) (x 2)) (lambda (n) (+ n 3))) work in elisp?         


Author: Tahsin Alam
Date: May 30, 2008 10:03

As the subject says - why does the following expression give error when I try
to evaluate it in the *scratch* buffer?

((lambda (x) (x 2)) (lambda (n) (+ n 3)))

---

This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.

As the subject says - why does the following expression give error when I try to evaluate it in the *scratch* buffer?

((lambda (x) (x 2)) (lambda (n) (+ n 3)))

---

This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
2 Comments
Re: newbie questions: why doesn't ((lambda (x) (x 2)) (lambda (n) (+ n 3))) work in elisp?         


Author: Joost Diepenmaat
Date: May 30, 2008 14:27

Tahsin Alam db.com> writes:
> As the subject says - why does the following expression give error when I try to evaluate it in the *scratch* buffer?
>
> ((lambda (x) (x 2)) (lambda (n) (+ n 3)))

Because ((some call evaluating to a function)) isn't valid in emacs
lisp, which also means

(lambda (x) (x 2))

has no real meaning in elisp (it does in scheme, but not in elisp or
common lisp, because elisp and cl have separate namespaces for
functions and variables). You want either

(funcall (lambda (x) (funcall x 2)) (lambda (n) (+ n 3)))

or possibly

(list (lambda (x) (list x 2)) (lambda (n) (+ n 3)))

or some permutation of both.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
no comments
Re: newbie questions: why doesn't ((lambda (x) (x 2)) (lambda (n) (+ n 3))) work in elisp?         


Author: Joost Diepenmaat
Date: May 30, 2008 14:33

Joost Diepenmaat writes:
> Tahsin Alam db.com> writes:
>
>> As the subject says - why does the following expression give error when I try to evaluate it in the *scratch* buffer?
>>
>> ((lambda (x) (x 2)) (lambda (n) (+ n 3)))
>
> Because ((some call evaluating to a function)) isn't valid in emacs
> lisp, which also means
>
> (lambda (x) (x 2))

unless, of course, you've got a (defun x (y) ...) somewhere...
Show full article (0.88Kb)
no comments

RELATED THREADS
SubjectArticles qty Group
Re: newbie: pls explain use of lambdacomp.lang.scheme ·