# Recursive List - CDR - CAR ??

• 09-25-2005
Mr. Acclude
Recursive List - CDR - CAR ??
I can't find any tutorials or info on Recursive List - cdr / car. I dont know what to return in member, any hints :D

Code:

```bool eq(list atom1, list atom2)  // returns true if atom1 & atom2 are the saem atoms  // otherwise false bool member(list p, list q)   //q is an atomp; p is a list of atoms   // member returns true if q is a member```
Code:

```bool eq(list atom1, list atom2)   if (atom1 == atom2)     return true;     return false; bool member(list p, list q)   if(is_null(p)       return false;   return ??????```
• 09-25-2005
valis
use lisp?
Not sure if this is what you mean, but:
Code:

```for each member of q {   if current member is p     return true } return false```
• 09-26-2005
Rashakil Fol
Something like this nearly-C pseudocode perhaps?

Code:

```bool member(list p, list q)     if (is_null(p))         return false     if (eq(q, car(p)))         return true     return member(cdr(p), q)```
In C and C++, the || operator is a branching operator. You could replace your '?????' with eq(q, car(p)) || member(cdr(p), q).

You do know what car and cdr represent, right? Car is the contained element in the first node of the list; cdr is the rest of the list.