1.1 Is it true that this is an atom?

ATOM

1.2 Is it true that this is an atom?

TURKEY

1.3 Is it true that this is an atom?

1492

1.4 Is it true that this is an atom?

3TURKEYS

1.5 Is it true that this is an atom?

L

1.6 Is it true that this is a list?

(ATOM)

1.7 Is it true that this is a list?

( ATOM TURKEY OR)

1.8 Is it true that this is a list?

(ATOM TURKEY) OR

1.9 Is it true that this is a list?

( (ATOM TURKEY) OR)

1.10 Is it true that this is an S-expression?

XYZ

1.11 Is it true that this is an S-expression?

(X Y Z)

1.12 Is it true that this is an S-expression?

( (X Y) Z)

1.13 Is it true that this is a list?

(HOW ARE YOU DOING SO FAR)

1.14 How many S-expressions are in the list

(HOW ARE YOU DOING SO FAR)
and what are they?

1.15 Is it true that this is a list?

( ( (HOW) ARE) ( (YOU) (DOING SO) )
FAR)

1.16 How many S-expressions are in the list?

( ( (HOW) ARE) ( (YOU) (DOING SO)
) FAR) and what are they?

1.17 Is it true that this is a list?

( )

1.18 Is it true that this is a list?

( (
) (
) ( ) ( ) )

1.19 What is the CAR of L, Where L is the argument

(A B
C)

1.20 What is the CAR of L, Where L is the argument

( (A B C)
X Y Z)

1.21 What is the CAR of L, Where L is the argument

HOTDOG

1.22 What is the CAR of L, Where L is the argument

(
)

** PRINCIPLE No. 1: **CAR is only defined for non-null lists.

1.23 What is the CAR of L, where L is the argument

( (
(HOTDOGS) ) (AND) (PICKLE) RELISH)

1.24 What is (CAR L), where L is the argument

( (
(HOTDOGS) ) (AND)
(PICKLE) RELISH)

1.25 What is the (CAR (CAR L) ), Where L is the argument

(
(HOTDOGS) ) (AND))

1.26 What is the CDR of L, where L is the argument

(A B
C)

Note: “CDR” is pronounced
“couder”.

1.27 What is the CDR of L, where L is the argument

( (A B C)
X Y Z)

1.28 What is (CDR L), where L is the argument

(
(X) T R)

1.29 What is (CDR A), where A is the argument

HOTDOGS

1.30 What is (CDR L), where L is the argument

(
)

** Principle No. 2:** CDR is only defined for non-null lists;
the CDR of any list is always another list.

1.31 What is (CAR (CDR L) ), where L is the argument

( (B) (X
Y) ( (C)
) )

1.32 What is (CDR (CDR L) ), where L is the argument

( (B) (X
Y) ( (C)) )

1.33 What is (CDR (CAR L) ), where L is the argument

( A (B
(C) ) D)

1.34 What does (CAR L) take as an argument?

1.35 What does (CDR L) take as an argument?

1.36 What is the CONS of the atom A and the list L,
where A is the argument PEANUT, and L is the argument
(BUTTER

AND JELLY)
This can alternatively
be asked (CONS A L). Read: “CONS the atom A onto the list L.”

1.37 What is the CONS of S and L, where S is (MAYONNAISE AND), and L is (PEANUT BUTTER AND JELLY)

1.38 What is (CONS S L), where S is ( (HELP) THIS), and L is (IS VERY ( (HARD) TO LEARN) )

1.39 What does CONS take as its arguments?

1.40 What is (CONS S L), where S is (A B (C) ), and L is ( )

1.41 What is (CONS S L), where S is A, and L is ( )

1.42 What is (CONS S L), where S is (A B (C) ), and L is B

1.43 What is (CONS S L), where S is A, and L is B

** Principle No. 3:** The second argument of (CONS S L) must
be a list, and the result must also be a list.

1.44 What is (CONS S (CAR L) ), where S is A, and L is ( (B) C C)

1.45 What is (CONS S (CDR L) ), where S is A, and L is ( (B) C D)

1.46 Is it true that the list, L is the null list, where L is ( )?

The question is alternatively
read as: (NULL L).

1.47 Is (NULL L) true or false, where L is the argument (A B C)

1.48 Is (NULL L) true or false, where L is the argument A

1.49 Is it true, or false, that S is an atom, where S is the argument HARRY

1.50 Is (ATOM S) true, or false, where S is HARRY

1.51 Is (ATOM S) true, or false, where S is (HARRY HAD A HEAP OF APPLES)

1.52 How many arguments does ATOM take? What are they?

1.53 Is

1.54 Is (ATOM (CDR L) ) true or false, where L is (HARRY HAD A HEAP OF APPLES)

1.55 Is (ATOM (CAR (CDR L) ) ) true or false, where L is (SWING LOW SWEET CHERRY)

1.56 Is (ATOM (CAR (CDR L) ) ) true or false, where L is (SWING (LOW SWEET) CHERRY)

1.57 True or False: A1 and A2 are the same atom, where A1 is HARRY,and A2 is HARRY

1.58 Is (EQ A1 A2) true or false, where A1 is the argument HARRY, and A2 is the argument HARRY.

1.59 Is (EQ A1 A2) true or false, where A1 is the argument is MARGARINE,and A2 is BUTTER

1.60 How many arguments does EQ take, and what are they?

1.61 Is (EQ A L) true, or false where A is STRAWBERRY, and L is (STRAWBERRY)

** Principle No. 5: **(EQ A1 A2) takes two
arguments.
Both of the arguments must be atoms, which begin with letters.

1.62 Is (EQ (CAR L) A) true or false where L is (MARY HAD A LITTLE CHOP),and A is MARY.

1.63 Is (EQ (CDR L) A) true or false where L is (SOURED MILK), and A is MILK

1.64 Is (EQ (CAR L) (CAR (CDR L) ) ) true or false where L is (BEANS BEANS ARE GOOD FOR YOUR HEART)

__Chapter 2__

2.1 True or False: (ISLAT L) where L is (JACK SPRAT COULD EAT NO CHICKEN FAT)

2.2 True or False: (ISLAT L) where L is ( (JACK) SPRAT COULD EAT NO CHICKEN FAT)

2.3 True or False: (ISLAT L) where L is (JACK (SPRAT COULD) EAT NO CHICKEN FAT)

2.4 True or False: (ISLAT L) where L is ( )

2.5 True or False: a LAT is a list of atoms

2.6 Write the function (ISLAT L), using some but not
necessarily all of the following functions: CAR, CDR, CONS,
NULL,

ATOM and
EQ

2.7 This is the function (ISLAT L) defined with the
help of the functions,NULL, CAR, CDR and ATOM

(DEFUN ISLAT(L)

(COND

( (NULL L) T)

( (ATOM (CAR L) ) (ISLAT(CDR L) ) )

(T F)

)

)

What is the value of (ISLAT L),
where L is the argument (BACON AND EGGS)?

2.8 How do you arrive at the answer T for the function (ISLAT L)?

2.9 What is the first question asked by (ISLAT L)?

2.10 What is meaning of the line ( (NULL L) T), where L is (BACON AND EGGS)?

2.11 What is next question?

2.12 What is the meaning of the line ( (ATOM (CAR L) (ISLAT (CDR L) ) ), where L is (BACON AND EGGS)?

2.13 What is the meaning of (ISLAT (CDR L) )?

2.14 Now what is the argument L for ISLAT?

2.15 What is the next question?

2.16 What is the meaning of the line ( ( NULL L) T) where L is now (AND EGGS)

2.17 What is the next question that must be asked?

2.18 What is the meaning of the line ( (ATOM (CAR L) ) (ISLAT (CDR L)) ) where L is (AND EGGS)?

2.19 What is the meaning of (ISLAT (CDR L) )

2.20 what is the next question?

2.21 What is the meaning of the line ( (NULL L) T) where L is now (EGGS)

2.22 What is the next question that must be asked?

2.23 What is the meaning of the line ( (ATOM (CAR L) ) (ISLAT (CDR L) ) ) where L is now (EGGS)

2.24 What is the meaning of (ISLAT (CDR L) ) ?

2.25 What is the argument for ISLAT?

2.26 What is the meaning of the line ( (NULL L) T) where L is now ( )

2.27 Do you remember the problem about (ISLAT L)

2.28 Can you describe what the function ISLAT does in your own words?

2.29 This is the function (ISLAT L) again:

(DEFUN ISLAT(L)

(COND

( (NULL L) T)

( (ATOM (CAR L) ) (ISLAT (CDR L) ) )

(T F)

)

)

What is the value of (ISLAT L),where L is now (BACON (AND EGGS)
)?

2.30 What is the first question to be asked?

2.31 What is the meaning of the line ( (NULL L) T) where L is (BACON (AND EGGS) )

2.32 What is the next question?

2.33 What is the meaning of the line ( (ATOM (CAR L) ) (ISLAT (CDR L) ) ) where L is (BACON (AND EGGS) )

2.34 What is the meaning of (ISLAT (CDR L) )?

2.35 What is the meaning of the line ( (NULL L) T) where L is ( (AND EGGS) )

2.36 What is the next question?

2.37 What is the meaning of the line ( (ATOM (CAR L) ) (ISLAT (CDR L) ) ) where L is ( (AND EGGS))

2.38 What is the next question?

2.39 What is the meaning of the question T?

2.40 Is T true?

2.41 T

2.42 Why is T the last question?

2.43 What is the meaning of the line (T F)

2.44 What is the meaning of the line

) ) )

2.45 Can you describe how we arrived at the value F for (ISLAT L) where L is (BACON (AND EGGS) )?

2.46 Is it true or false that A is a member of LAT, where A is the argument
TEA and LAT is the argument (COFFEE TEA
OR

MILK)

2.47 Is (MEMBER A LAT) true or false where A is POACHED and LAT is (FRIED EGGS AND SCRAMBLED EGGS)

2.48 This is the function (MEMBER A LAT):

(DEFUN MEMBER (A LAT)

(COND

( (NULL LAT) F)

( (EQ (CAR LAT) A) T)

(T (MEMBER A (CDR LAT) ) )

)

)

What is the value of (MEMBER A LAT) where A is MEAT and LAT is (MASHED
POTATOES AND MEAT GRAVY)

2.49 How do you arrive at the value T for the above function?

2.50 What is the first question asked by (MEMBER A LAT)

** Commandment No. 1:** Thou shall always ask NULL as the first
question in describing any function

2.51 What is the meaning of the line ( (NULL LAT) F) where LAT is (MASHED POTATOES AND MEAT GRAVY)

2.52 What is the next question?

2.53 What is the meaning of the line ( (EQ (CAR LAT) A) T) where
A is MEAT and LAT is (MASHED POTATOES
AND

MEAT GRAVY)

2.54 What is the next question?

2.55 Is T really a question?

2.56 Give an example of a question to which the answer is contained in the question

2.57 What is the meaning of the line (T (MEMBER A (CDR LAT) ) )

2.58 What are the arguments for MEMBER now?

2.59 What is the next question?

2.60 Is (NULL LAT) true or false where LAT is (POTATOES AND MEAT GRAVY)

2.61 What do we do now?

2.62 What is the next question?

2.63 What is (EQ (CAR LAT) A) where A is MEAT and LAT is (POTATOES AND MEAT GRAVY)

2.64 What do we do now?

2.65 What is the next question?

2.66 What is T?

2.67 What is the meaning of the line (T (MEMBER A (CDR LAT) ) )?

2.68 What are the arguments of MEMBER now?

2.69 What is the next question?

2.70 What do we do now?

2.71 What is the next question?

2.72 What do we do now?

2.73 What is the next question?

2.74 What is the value of the line (T (MEMBER A (CDR LAT) ) )?

2.75 What do we do now?

2.76 What are the new arguments?

2.77 What is the next question?

2.78 What do we do now?

2.79 What is the next question?

2.80 What is the value of the line ( (EQ (CAR LAT) A) T)

2.81 What is the value of the function (MEMBER A LAT) where A is MEAT and LAT is (MEAT GRAVY)

2.82 What is the value of the function (MEMBER A LAT) where A is MEAT and LAT is (AND MEAT GRAVY)

2.83 What is the value of the function (MEMBER A LAT) where A is MEAT
and LAT is (POTATOES AND MEAT

GRAVY)

2.84 What is the value of the function (MEMBER A LAT) where A is MEAT
and LAT is (MASHED POTATOES AND

MEAT GRAVY)

2.85 Just to make sure you have it right, let’s run through it again quickly, what is the value of

(DEFUN MEMBER (A LAT)

(COND

( (NULL LAT) F)

( (EQ (CAR LAT) A) T)

(T (MEMBER A (CDR LAT) ) )

)

)

Where A is MEAT and Lat is (MASHED POTATOES AND MEAT GRAVY)

2.86 (NULL LAT)

2.87 (EQ (CAR LAT) A)

2.88 T

2.89 (NULL LAT)

2.90 (EQ (CAR LAT) A)

2.91 T

2.92 (NULL LAT)

2.93 (EQ (CAR LAT) A)

2.94 T

2.95 (NULL LAT)

2.96 (EQ (CAR LAT) A)

2.97 What is the value of (MEMBER A LAT) where A is MEAT and LAT is (MEAT GRAVY)

2.98 What is the value of (MEMBER A LAT) where A is MEAT and LAT is (AND MEAT GRAVY)

2.99 What is the value of (MEMBER A LAT) where A is MEAT and LAT is (POTATOES AND MEAT GRAVY)

2.100 What is the value of (MEMBER A LAT) where A is MEAT and LAT is
(MASHED POTATOES AND MEAT

GRAVY)

2.101 What is the value of (MEMBER A LAT) where A is LIVER and LAT is (BAGELS AND LOX)

2.102 (NULL LAT)

2.103 (EQ (CAR LAT) A)

2.104 T

2.105 (NULL LAT)

2.106 (EQ (CAR LAT) A)

2.107 T

2.108 (NULL LAT)

2.109 (EQ (CAR LAT) A)

2.110 T

2.111 (NULL LAT)

2.112 What is the value of (MEMBER A LAT) where A is LIVER and LAT is ( )

2.113 What is the value of (MEMBER A LAT) where A is LIVER and LAT is (LOX)

2.114 What is the value of (MEMBER A LAT) where A is LIVER and LAT is (AND LOX)

2.115 What is the value of (MEMBER A LAT) where A is LIVER and LAT is (BAGELS AND LOX)

__Chapter 3__

3.1 What is (REMBER A LAT) where A is MINT and LAT is (LAMB CHOPS AND MINT JELLY)

3.2 (REMBER A LAT) where A is MINT and LAT is (LAMB CHOPS AND MINT FLAVOURED MINT JELLY)

3.3 (REMBER A LAT) where A is TOAST and LAT is (BACON LETTUCE AND TOMATO)

3.4 (REMBER A LAT) where A is CUP and LAT is (COFFEE CUP TEA CUP AND HICK CUP)

3.5 What does (REMBER A LAT) do?

3.6 What steps will we use to do this?

3.7 How do we ask if A is the same as (CAR LAT)?

3.8 What would be the value of (REMBER A LAT) if A is the same as (CAR LAT) ?

3.9 What do we do if A is not the same as (CAR LAT)?

3.10 How do we find out if A is somewhere in the rest of LAT?

3.11 Let us now use the ideas developed so far to write the function REMBER:

(DEFUN
REMBER (A LAT)

(COND

( (EQ (CAR LAT) A) (CDR LAT) )

(T (REMBER A (CDR LAT) ) )

) )

)

What is missing from here?

3.12 Now we think that this is the function REMBER:

(DEFUN REMBER (A LAT)

(COND

( (NULL LAT) ( ) )

( (EQ (CAR LAT) A) (CDR LAT) )

(T (REMBER A (CDR LAT) ) )

) )

)

What is the value of (REMBER A LAT) where A is BACON and LAT is (BACON
LETTUCE AND TOMATO)

3.13 Now lets see if this function works. What is the first question?

3.14 What do we do now?

3.15 (EQ (CAR LAT) A)

3.16 Is this the correct value of the function?

3.17 But did we really use a good example?

3.18 What does a (REMBER A LAT) do?

3.19 What steps do we use to do this?

3.20 What is the value of (REMBER A LAT) where A is AND and LAT is (BACON LETTUCE AND TOMATO)

3.21 Let us see if this function works. What is the first question asked by REMBER?

3.22 What do we do now?

3.23 (EQ (CAR LAT) A)

3.24 What is the meaning of the line ( T REMBER A (CDR LAT) ) )

3.25 (NULL LAT)

3.26 (EQ (CAR LAT) A)

3.27 What is the meaning of the line ( T REMBER A (CDR LAT) ) )

3.28 (NULL LAT)

3.29 (EQ (CAR LAT) A)

3.30 What is the value of the function (REMBER A LAT)

3.31 Is this correct?

3.32 What did we do wrong?

3.33 How can we keep from losing the atoms BACONS and LETTUCE?

** Commandment No. 2:** Thou shall use CONS to
build lists.

3.34 Let’s just see what happens when we use CONS:

(DEFUN REMBER (A LAT)

(COND

( (NULL LAT) ( ) )

( (EQ (CAR LAT) A) (CDR LAT) )

(T (CONS (CAR LAT) (REMBER A (CDR LAT) ) ) )

)

)

Now, what is the value of (REMBER A LAT) where A is AND and LAT is
(BACON LETTUCE AND TOMATO)

3.35 What is the first question?

3.36 What do we do now?

3.37 (EQ (CAR LAT) A)

3.38 What is the meaning of the line (T (CONS (CAR LAT) (REMBER
A (CDR LAT) ) ) )

where A is AND and

LAT is (BACON LETTUCE AND
TOMATO)

3.39 What is the meaning of (REMBER A (CDR LAT) )

3.40 (NULL LAT)

3.41 (EQ (CAR LAT) A)

3.42 What is the meaning of the line (T (CONS (CAR LAT) (REMBER A (CDR LAT) ) ) )

3.43 What is the meaning of (REMBER A (CDR LAT) )

3.44 (NULL LAT)

3.45 (EQ (CAR LAT) A)

3.46 What is the value of the line ( (EQ (CAR LAT) A) (CDR LAT) )

3.47 Are we finished?

3.48 We now have a value for (REMBER A (CDR LAT) ),

where A is AND and (CDR
LAT) is (AND TOMATO) This value is (TOMATO). This is not the final
value, so what

must we do?

3.49 What is the result when we CONS LETTUCE onto (TOMATO)

3.50 What does (LETTUCE TOMATO) represent?

3.51 Are we finished yet?

3.52 We now have a value for (REMBER A (CDR LAT) ), where A was AND
and (CDR LAT) was (LETTUCE AND

TOMATO) This value was (LETTUCE TOMATO).
This is not the final value,
so what must we do?

3.53 What is the result when we CONS BACON onto (LETTUCE TOMATO)

3.54 What does (BACON LETTUCE TOMATO) represent?

3.55 Are we finished yet?

3.56 Can you put in your words how we arrived at the final value (BACON LETTUCE TOMATO)

3.57 What is the value of the function

(DEFUN REMBER (A LAT)

(COND

( (NULL LAT) ( ) )

( (EQ (CAR LAT) A) (CDR LAT) )

(T (CONS (CAR LAT) (REMBER A (CDR LAT) ) ) )

) )

)

Where A is AND and LAT is (BACON LETTUCE AND TOMATO)

3.58 (NULL LAT)

3.59 (EQ (CAR LAT) A)

3.60 T

3.61 What is the meaning of (CONS (CAR LAT) (REMBER A (CDR LAT) ) ) )

3.62 (NULL LAT)

3.63 (EQ (CAR LAT) A)

3.64 T

3.65 What is the meaning of (CONS (CAR LAT) (REMBER A (CDR LAT) ) ) )

3.66 (NULL LAT)

3.67 (EQ (CAR LAT) A)

3.68 What is the value of the line

3.69 Now what?

3.70 Now what?

3.71 Now that we have completed REMBER, try this example:

(REMBER A LAT) where A is
SAUCE and LAT is (SOY SAUCE AND TOMATO SAUCE)

3.72 What is (FIRSTS L) where L is ( (APPLE PEACH PUMPKIN) (PLUM PEAR
CHERRY) (GRAPE RAISIN PEA)

(BEAN
CARROT EGGPLANT)

3.73 What is (FIRSTS L) where L is ( (A B) (C D) (E F) )

3.74 What is (FIRSTS L) where L is ( )

3.75 What is (FIRSTS L) where L is ( (FIVE PLUMS) (FOUR) (ELEVEN GREEN ORANGES) )

3.76 In your own words what does (FIRSTS L) do?

3.77 See if you can write the functions FIRSTS

Remember the
Commandments!

3.78 Why (DEFUN FIRSTS ( L ) ?

3.79 Why ( COND ?

3.80 Why ( ( NULL L) ) ?

3.81 Why (T ?

3.82 Why ( CONS ?

3.83 Why (FIRSTS (CDR L) ) ?

3.84 Why ) ) ) ?

3.85 Keeping in mind the definition of ( FIRSTS L), what is a typical
element of the value of (FIRSTS L), where L is ( ( A B )
(

C D ) ( E F) )

3.86 What is another typical element?

3.87 Suppose there was a function (SECONDS L) what would
be a typical element of the value of (SECONDS L)
where L

is ( (A
B) (C D) (E F) )

3.88 How do we describe a typical element for (FIRSTS L)

3.89 As we find a typical element for (FIRSTS L) what do we do with it?

** Commandment No. 3:** Thou shall always
realize when
building a list, thou need only describe the first typical element, and
then CONS it onto the natural recursion.

NOTE: You have just read an important statement in this page. Please read it again.

3.90 From Commandment No. 3, we can now fill in more of the function ( FIRSTS L). what does the last line look like now?

3.91 What does the function do?

(DEFUN FIRSTS
( L )

(COND

( (NULL L) ( ) )

( T (CONS (CAR (CAR L) ) (FIRSTS (CDR L) ) ) )

Where L is ( (A B) (C D) (E F) )

3.92 (NULL L) where L is ( (A B) (C D) (E F) )

3.93 What is the meaning of the line ( T (CONS (CAR L) ) (FIRSTS (CDR L) ) ) )

3.94 (NULL L) where L is ( (C D) (E F) )

3.95 What is the meaning of the line ( T (CONS (CAR L) ) (FIRSTS (CDR L) ) ) )

3.96 (NULL L) where L is ( (E F) )

3.97 What is the meaning of the line ( T (CONS (CAR L) ) (FIRSTS (CDR L) ) ) )

3.98 (NULL L)

3.99 Now what is the value of the line ( (NULL L) )

3.100 What do we need to CONS atoms onto?

3.101 What value can we give the function in the case that (NULL L) is true for the purpose of CONS ing?

3.102 With ( ) as a value, we now have three CONS steps to go back and pick up.

I. We need to: 1. CONS E onto (
)

2. CONS C onto the value of 1

3. CONS A onto the value of 2

or alternatively

II. We need to: 1. CONS A onto the value of 2

2. CONS C onto the value of 3

3. CONS E onto ( )

or alternatively

III. We need to CONS A onto the CONS of C onto the CONS of E onto ( )

In any case what is the final value of (FIRSTS L) ?

3.103 With which of the three alternatives are you most comfortable?

3.104 (INSERTR OLD NEW LAT) where OLD is FUDGE, NEW is TOPPING and LAT
is (ICE CREAM WITH FUDGE

FOR DESSERT)

3.105 (INSERTR OLD NEW LAT) where OLD is AND, NEW is JALAPENO and LAT
is (TACOS TAMALES AND

SALSA)

3.106 (INSERTR OLD NEW LAT) where OLD is D, NEW is E and LAT is (A B C D F G D H)

3.107 In your own words what does (INSERTR OLD NEW LAT) do?

3.108 See if you can write the function (INSERTR OLD NEW LAT)

3.109 What is the value of the INSERTR we just wrote, where OLD is FUDGE,
NEW is TOPPING and LAT is
(ICE

CREAM WITH FUDGE FOR DESSERT)

3.110 Notice that so far this is the same as REMBER, but for (INSERTR OLD NEW LAT)

What do we do, where (EQ (CAR LAT) OLD) is true?

3.111 How is this done?

3.112 Now we have

(DEFUN INSERTR (OLD
NEW LAT)

(COND

( (NULL LAT) ( ) )

( (EQ (CAR LAT) OLD) (CONS NEW (CDR LAT) ) )

(T (CONS (CAR LAT) (INSERTR OLD NEW (CDR LAT) ) ) )

)

)

What is (INSERTR OLD NEW LAT) where OLD is FUDGE, NEW is TOPPING and
LAT is (ICE CREAM WITH FUDGE FOR DESSERT)

3.113 Is this the list we wanted?

3.114 What still needs to be done?

3.115 How can we include OLD before NEW?

3.116 Now you should be able to write the rest of the function
(INSERTR OLD NEW LAT)

Do it.

3.117 Now try (INSERTL OLD NEW LAT)

Hint: INSERTL inserts the atom NEW to the left of the first occurrence
of the atom OLD

3.118 Did you think of a different way to do that?

3.119 Now try to write (SUBST OLD NEW LAT)

HINT: (SUBST OLD NEW LAT)
replaces the first occurrence of OLD in the LAT with the atom NEW. For
Example

where OLD is
FUDGE, NEW is TOPPING and
LAT is (ICE CREAM WITH FUDGE FOR DESSERT), the value
is

(ICE CREAM WITH
TOPPING FOR DESSERT). Now you have the
idea.

__ANSWERS__

__Chapter 1__

1.1 Yes

Because ATOM is a string of characters
beginning with an A.

1.2 Yes

Because TURKEY is a string of
characters beginning with a letter

1.4 No

Because 3TURKEYS is a string of characters
beginning with a digit.

1.5 Yes

Because L is a string of ---one----
characters beginning with a letter.

1.6 Yes

Because (ATOM) is an atom enclosed by
parentheses.

1.7 Yes

Because it is a collection of atoms
enclosed by parentheses.

1.9 Yes

Because the two S-expressions are now
enclosed by parentheses.

1.10 Yes

Because all atoms
are S-expressions.

1.11 Yes

Because it is a list.

1.12 Yes

Because all lists
are S-expressions.

1.13 Yes

Because it is a collection
of S-expressions enclosed by parentheses.

1.14 ( 6 ) HOW, ARE, YOU, DOING, SO and FAR.

1.15 Yes

Because it is a collection
of S-expressions enclosed by parentheses.

1.16 ( 3 )

( ( HOW ) ARE ), (
( YOU ) ( DOING SO ) ) and FAR

1.18 Yes

Because it is a collection
of S-expressions enclosed by parentheses

1.19 A

Because A is the first atom
of this non-null list.

1.20 (A B C)

Because (A B C) is the first
S-expression of this non-null list.

1.21 No answer

Since you cannot ask for
the CAR of an atom.

1.22 No answer

Since you cannot ask for
the CAR of the null list.

1.26 (B C)

Because (B C) is the list
L, without (CAR L).

1.28 (T R)

Since (CDR L) is just another
way to ask for "The CDR of the list L".

1.29 No answer

Since you cannot ask for
the CDR of an atom

1.30 No answer

Since you cannot ask for
the CDR of the non null list.

1.31 (X Y)

Because ( (X Y) ( (C) )
) is (CDR L) and (X Y) is the CAR of (CDR L).

1.32 ( ( ( C ) ) )

Because ( (X Y) ( (C) )
) is (CDR L) and ( ( (C) ) ) is the CDR of (CDR L).

1.33 No answer

Since (CAR L) is an atom
and CDR will not take an atom for an argument;

see Principle No.2.

1.34 (CAR L) takes any non-null list as its argument L.

1.35 (CDR L) takes any non-null list as its argument L.

1.36 (PEANUT BUTTER AND JELLY)

Because CONS sticks an atom
onto the front of a list.

1.38 ( ( (HELP) THIS) IS VERY ( (HARD) TO LEARN) ).

1.40 ( (A B (C) ) )

Since ( ) is a list.

1.42 No answer

Since the second argument
L must be a list

1.43 No answer

why? See Principle
No. 3

1.46 Yes

Because it is the
list composed of zero S-expressions.

1.47 False

Because it is a non-null
list

1.48 No answer

Because you cannot ask (
NULL L) of an atom.

1.49 True

Because HARRY is a string
of characters beginning with a letter.

1.50 True

Since (ATOM S) is just another
way to ask: "Is it true or false, that S is an atom?"

1.51 False

Since the argument S is
a list.

1.52 ATOM takes one argument, which is any S-expression.

1.53 True

Because (CAR L) is HARRY
and HARRY is an atom.

1.55 True

Because (CDR L) is (LOW
SWEET CHERRY) and (CAR (CDR L) is (LOW SWEET)

which is a list.

1.56 False

Because (CDR L) is ( (LOW
SWEET) CHERRY) and (CAR (CDR L) is (LOW

SWEET) which is a list.

1.57 True

Because both A1 and A2 are
HARRY.

1.58 True

Because (EQ A1 A2) is just
another way to ask: "Are A1 and A2 the same atom?".

1.59 False

Since the arguments A1 and
A2 are different atoms.

1.60 EQ takes two arguments , both of which must be atoms.

1.61 No answer

Since neither argument of
EQ can be a list.

1.62 True

Because (CAR L) is the atom
MARY and the argument A is also the atom MARY.

1.63 No answer

See
Principles No. 2 and
5

1.64 True

This compares the first
and second atoms in the list.

__Chapter 2__

2.1 True

Because each S-expression in L is an
atom.

2.2 False

Since (CAR L) is a list

2.3 False

Since one of the S-expression in L is
a list.

2.4 True

Because ( ) contains no
lists, and because it does not contain any lists, it must be a LAT

2.5 True

Note: Every LAT is a list, but
not every list is a LAT.

2.14 Now the argument L is (CDR L) which is (AND EGGS).

2.24 (ISLAT (CDR L) finds out if the rest of the L is composed only
of atoms by referring us back again to the original
function

(ISLAT L),but with L
replaced by (CDR L)

2.25 ( )

2.29 False

since the list L contains
a S-expression that is a list.

2.40 Yes

because the question T is
always true!

2.42 Because we do not need to ask any more questions.

2.46 True

Because one of the atoms
of the LAT (COFFEE TEA OR MILK) is the same as the atom A, TEA.

2.47 False

Since A is not one of the
atoms of the LAT.

2.48 True

because the atom MEAT is
one of the atoms of the LAT (MASHED POTATOES AND MEAT GRAVY)

2.50 (NULL LAT)

Note: This is also
the first question asked by (ISLAT L).

2.55 Yes

T is question whose
answer is always true.

2.56 Here’s ours:

“what color is an orange?”.

2.58 A is MEAT and LAT is now (CDR LAT) --- (POTATOES AND MEAT GRAVY).

2.59 (NULL LAT)

Remember Commandment No.
1

2.68 A is MEAT, and LAT is (AND MEAT GRAVY)

2.70 Ask the next question

Since (NULL LAT) is false)

2.75 Recurse ---- refer to the original function with new arguments.

2.76 A is MEAT and LAT is (MEAT GRAVY)

2.78 Ask the next question.

Since (NULL LAT) is false.

2.80 T

Because (CAR LAT) which
is MEAT and A which is MEAT are the same atom.

2.81 T

Because we have now found
that MEAT is a member of (MEAT GRAVY)

2.82 T

Because MEAT is also a member
of the LAT (AND MEAT GRAVY)

2.83 T

Because MEAT is also a member
of the LAT (POTATOES AND MEAT GRAVY)

2.86 No

Move to the next line.

2.87 No

Move to the next line.

2.88 Yes

Recurse with A and
(CDR LAT), where A is MEAT and (CDR LAT) is (POTATOES AND MEAT GRAVY).

2.89 No

Move to the next line.

2.90 No

Move to the next line.

2.91 Yes

Recurse with A and
(CDR LAT), where A is MEAT and (CDR LAT) is (AND MEAT GRAVY)

2.92 No

Move to the next line.

2.93 No

Move to the next line.

2.94 Yes

Recurse with A and
(CDR LAT), where A is MEAT and (CDR LAT) is (MEAT GRAVY)

2.95 No

Move to the next line.

2.96 Yes

The value of this
function is T.

2.100 T ( T sometimes appears as *T*)

2.101 F (F sometimes appears as NIL)

2.102 No

Move to the
next line.

2.103 No

Move to the
next line.

2.104 Yes

Recurse
with A and (CDR LAT) where A is LIVER and (CDR LAT) is (AND LOX)

2.105 No

Move to the
next line.

2.106 No

Move to the
next line.

2.107 Yes

Recurse
with A and (CDR LAT) where A is LIVER and (CDR LAT) is (LOX)

2.108 No

Move to the
next line.

2.109 No

Move to the
next line.

2.110 Yes

Recurse
with A and (CDR LAT) where A is LIVER and (CDR LAT) is ( )

__Chapter 3__

3.1 (LAMB CHOPS AND JELLY)

(REMBER stands for REMove the memBER

3.2 (LAMB CHOPS AND FLAVOURED MINT JELLY)

3.3 (BACON LETTUCE AND TOMATO)

3.4 (COFFEE TEA CUP AND HICK CUP)

3.6 First we will compare A with (CAR LAT). We will want to build a list from left to right.

3.9 We will want to keep (CAR LAT), but also find out if A is somewhere in the rest of the LAT.

3.11 Obviously, we have forgotten Commandment No. 1! Now, we rewrite (REMBER A LAT).

3.14 Move to the next line and ask the next question.

3.16 Yes

Because the above
list is the original list without the atom BACON.

3.17 who knows?

But the proof of the pudding
is in the eating, so let’s try another example.

3.22 Move to the next line, and ask the next question.

3.23 No

Move to the next line.

3.25 No

Move to the next line.

3.26 No

Move to the next line.

3.27 Recurse, where A is AND and (CDR LAT) is (AND TOMATO)

3.28 No

Move to the next line, and
ask the next question.

3.31 No

Since (TOMATO) is not the
list (BACON LETTUCE AND TOMATO) with only A --- AND--- removed.

3.32 We dropped AND, but we also lost all the atoms preceeding AND.

3.33 We use CONS “The Magnificient”. Remember CONS from Chapter 1.

3.36 Move to the next line of the function and ask the next question.

3.37 No

Move to the next line.

3.40 No

Move to the next line.

3.41 No

Move to the next line.

3.43 This refers us back to the original function with LAT replaced by (CDR LAT) --- (AND TOMATO).

3.44 No

Move to the next line.

3.60 T, so the value is (CONS (CAR LAT) (REMBER A (CDR LAT) ) )

3.64 T, so the value is (CONS (CAR LAT) (REMBER A (CDR LAT) ) )

3.69 CONS (CAR LAT) – LETTUCE --- onto (TOMATO) ---see answer# 3.60
forming

(LETTUCE TOMATO)

3.71 (REMBER A LAT) is (SOY AND TOMATO SAUCE)

3.78 Because we always state the function, after the "DEFUN", then the arguments of the function.

3.79 Because it is necessary part of the function, and must always be used.

3.82 Because we are building a list. ---Commandment No. 2

3.83 Because we can only look at one S-expression at a time. In order to do this we must recurse.

3.88 By taking the CAR of (CAR L) --- (CAR (CAR L) ). See chapter 1.

3.89 We CONS it onto the recursion --- (FIRSTS (CDR L) ).

3.90 (T (CONS (CAR L) ) (FIRSTS (CDR L) ) ) )

TYPICAL ELEMENT, NATURAL
RECURSION

3.92 No

So move to the next line.

3.94 No

So move to the next line.

3.95 Save (CAR (CAR L) ), and recurse with (FIRSTS (CDR L) ).

3.96 No

So move to the next line.

3.97 Save (CAR (CAR L) ), and recurse with (FIRSTS (CDR L) ).

3.99 There is no value, something is missing.

3.100 A list

Remember Principle
No. 3 -- see chapter 1.

3.103 Correct!

Now you use
that one.

3.104 (ICE CREAM WITH FUDGE TOPPING FOR DESSERT)

3.105 (TACOS TAMALES AND JALAPENO SALSA)

3.109 (ICE CREAM WITH FOR DESSERT)

3.110 When (CAR LAT) is the same as OLD, we want to insert NEW to the right.

3.111 Let's try CONS NEW onto (CDR LAT).

3.112 (ICE CREAM WITH TOPPING FOR DESSERT)

3.113 No

We have only
replaced FUDGE with TOPPING.

3.114 Somehow we have to include the atom which is the same as OLD before the atom NEW.

3.115 Try CONSing OLD onto (CONS NEW (CDR LAT) )

3.117 This much is trivial ---- right?

Notice that this is the same as our second attempt at INSERTR.