How can I define the LAMBDA function in LISP? -



How can I define the LAMBDA function in LISP? -

i can't utilize @ lambda function, because error: argument apply/funcall not function: (lambda (e) (count_atoms m e)).

and code is:

> (defun count_atoms (m l) > (cond ((atom l) (cond ((equal m l) 1) > (t 0))) > (t (apply '+ > (mapcar '(lambda (e) (count_atoms m e)) > l)))))

for

(count_atoms 3 '( (3 3) 3 (4 4) 5))

it should print 3.

what wrong here?

use (mapcar #'(lambda (e) (count_atoms m e)) ..., "sharp" sign. same apply, utilize #'+.

writing #'(lambda .... ) same writing (function (lambda .... )). there's macro lambda lets away writing (lambda ... ) there.

see also:

clhs: apply clhs: function designator

lambda lisp common-lisp

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -