Re: Lisp Syntax - functions versus data



"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
.