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 ...
thanks
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/
in message <························@p10g2000cwp.googlegroups.com>, rich
(··········@yahoo.co.in') 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 ...
cdr isn't second, it's rest.
cadr is second.
--
·····@jasmine.org.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/
.::;===r==\
/ /___||___\____
//==\- ||- | /__\( MS Windows IS an operating environment.
//____\__||___|_// \|: C++ IS an object oriented programming language.
\__/ ~~~~~~~~~ \__/ Citroen 2cv6 IS a four door family saloon.