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
.



Relevant Pages

  • Re: Lisp Syntax - functions versus data
    ... being either evaluated, referring to data, or referring to ... which seems to have simpler syntax? ... "(defun mapcar. ...
    (comp.lang.lisp)
  • Re: Lisp Syntax - functions versus data
    ... being either evaluated, referring to data, or referring to ... which seems to have simpler syntax? ... Using APPEND is often inefficient. ...
    (comp.lang.lisp)
  • Lisp Syntax - functions versus data
    ... Not the S-expressions, mind you, but the rules for forms ... being either evaluated, referring to data, or referring to ... which seems to have simpler syntax? ...
    (comp.lang.lisp)
  • Re: Forms! syntax question
    ... >Where "TMS Switchboard" is the name of the form. ... >syntax if the name of the form is contained in a string variable? ... You can use *three* different syntaxes for referring to ... the sequential number in parentheses (not ...
    (microsoft.public.access.formscoding)
  • Re: Forms! syntax question
    ... > Subform control, but - though it's evidently legal here - it's not ... >>syntax if the name of the form is contained in a string variable? ... You can use *three* different syntaxes for referring to ... > the members of a collection: the sequential number in parentheses (not ...
    (microsoft.public.access.formscoding)