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
Post a Comment