Re: Lisp Syntax - functions versus data
- From: tar@xxxxxxxxxxxxx (Thomas A. Russ)
- Date: 27 Feb 2007 11:30:52 -0800
"S. Robert James" <srobertjames@xxxxxxxxx> writes:
I'm still struggling to master some of the finer points of Lisp
syntax. Not the S-expressions, mind you, but the rules for forms
being either evaluated, referring to data, or referring to
functions...
I'm trying:
(defun mapcar. (func lst)
(if (null lst)
()
(append (list (funcall func (car lst))) (mapcar. func (cdr
lst)))))
(= '(3 4 5 6) (mapcar. '(lambda (x) (+ 3 x)) '(0 1 2 3)))
but can't get it to work... how should this be quoted? Should I
switch to Scheme, which seems to have simpler syntax?
Um, what fails?
I just pasted your code into my lisp and it (generally) worked.
What results do you get from
(mapcar. '(lambda (x) (+ 3 x)) '(0 1 2 3))
The only problem I see is that the "=" function in Lisp is only defined
to work on numbers. Try using EQUAL instead.
--
Thomas A. Russ, USC/Information Sciences Institute
.
- References:
- Lisp Syntax - functions versus data
- From: S. Robert James
- Lisp Syntax - functions versus data
- Prev by Date: Re: Implementing REPL...
- Next by Date: Re: Implementing REPL...
- Previous by thread: Re: Lisp Syntax - functions versus data
- Next by thread: Optimizing sort-algorithm
- Index(es):
Relevant Pages
|