Simple defun list passing question 
Author Message
 Simple defun list passing question

I was wondering if anyone could tell me what the proper way to pass a list
in lisp to a function defined using defun.
I am basically trying to setup something like this :

(defun foo  (x)  
        (first (x)))

Basically I want to pass a list to the function and have it return the
first element of the list, and do any other functions that can be done on
lists. Basically after i load the lsp file i want to be able to type

(foo'(one two three))

and have foo perform operation on this list.
Any help on this  would be much appreciated.
Please reply to the email addresss becuase my new
server timeouts articles somewhat quickly.

SD



Tue, 14 May 2002 03:00:00 GMT  
 Simple defun list passing question


Quote:
>I was wondering if anyone could tell me what the proper way to pass a list
>in lisp to a function defined using defun.

The same way you pass anything else.

Quote:
>I am basically trying to setup something like this :

>(defun foo  (x)  
>    (first (x)))

>Basically I want to pass a list to the function and have it return the
>first element of the list, and do any other functions that can be done on
>lists. Basically after i load the lsp file i want to be able to type

Just refer to X as a variable:

(defun foo (x)
  (first x))

This is something really basic.  I'm curious how you could be doing
*anything* in Lisp if you didn't know this.

When you write (x) in your function, you're trying to call a function named
X rather than use the value of the variable.

--

GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.



Tue, 14 May 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Limitation of lambda list in DEFUN form?

2. Question in french (a simple question, very simple)

3. Newbie question - Passing a list to a proc

4. Simple list box question??

5. Simple Browse List Question

6. Simple Question about COLOURS in my List Box

7. Simple list.append() question

8. Simple del[] list question

9. Simple List Question, Please..

10. Novice question: (defun (setf f)) ???

11. List Element Writer -- Simple Question

12. pass a list (or list pointer) from C++ to tk

 

 
Powered by phpBB® Forum Software