list as an argument
Posted: Sat Dec 01, 2012 7:20 am
hello everybody I know this is simple question but please help me because I am very beginner .
my question is how to use a list as an argument in my functions .
for example when I found this function to insert an element in sorted list :
(defun sorted-list-insert (L E)
"Insert element E into a sorted list L to produce a new sorted list."
(if (null L)
(list E)
(if (> E (first L))
(cons (first L) (sorted-list-insert (rest L) E))
(if (= E (first L))
L
(cons E L)))))
how I can use the list (1 2 4 ) and the element 3
because when I tried to apply this function in this way
sorted-list-insert ((1 2 4) 3) I had this error (1 2 4) is not a function name try using symbol instead .
then I called it as :
(setq `x (1 2 4))
(sorted-list-insert (x 3)) I have undefined function x
please help me to do that
thanks
my question is how to use a list as an argument in my functions .
for example when I found this function to insert an element in sorted list :
(defun sorted-list-insert (L E)
"Insert element E into a sorted list L to produce a new sorted list."
(if (null L)
(list E)
(if (> E (first L))
(cons (first L) (sorted-list-insert (rest L) E))
(if (= E (first L))
L
(cons E L)))))
how I can use the list (1 2 4 ) and the element 3
because when I tried to apply this function in this way
sorted-list-insert ((1 2 4) 3) I had this error (1 2 4) is not a function name try using symbol instead .
then I called it as :
(setq `x (1 2 4))
(sorted-list-insert (x 3)) I have undefined function x
please help me to do that
thanks