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
list as an argument
Forum rules
Please respect your teacher's guidelines. Homework is a learning tool. If we just post answers, we aren't actually helping. When you post questions, be sure to show what you have tried or what you don't understand.
Please respect your teacher's guidelines. Homework is a learning tool. If we just post answers, we aren't actually helping. When you post questions, be sure to show what you have tried or what you don't understand.
Re: list as an argument
Code: Select all
(sorted-list-insert '(1 2 4) 3)
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.
Re: list as an argument
thank you very much
Actually , I have found very nice and helpful persons here thank you a lot
Actually , I have found very nice and helpful persons here thank you a lot