Re: car v/s first



rich wrote:
Hello all,
I am using the following code for some checking as ;

(defun validator (pat lst pattern-lst)

(cond
((null pattern-lst) T)

((AND(Equal (first pat) (first (first pattern-lst)))
(Equal (first lst)(second (first pattern-lst))))
T )

((Equal (first pat) (first (first pattern-lst))) nil)

(T(validator pat lst (cdr pattern-lst)))))

and the values for various parameters are

pat=(?x)
lst=(b)
patter-lst= (?x b)

now when i use the car and cdr functions in place of first and second
fucntions which i hve used in the code it gives me nil otherwise its
works fine findin the duplicates..if present.

Why is that so? are the car and first behave differently at times.. or
i am missing smthin ...

car and cdr behave like first and rest. If you want to express second, that's cadr.


Pascal

--
My website: http://p-cos.net
Closer to MOP & ContextL:
http://common-lisp.net/project/closer/
.



Relevant Pages

  • Re: car v/s first
    ... (defun validator (pat lst pattern-lst) ... now when i use the car and cdr functions in place of first and second ... are the car and first behave differently at times.. ...
    (comp.lang.lisp)
  • car v/s first
    ... (defun validator (pat lst pattern-lst) ... now when i use the car and cdr functions in place of first and second ... are the car and first behave differently at times.. ...
    (comp.lang.lisp)