abc
Chapter 1

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 (ATOM (CAR L) ) true or false, where L is (HARRY HAD A HEAP OF APPLES)

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.3 No
      Because 1942 is a string of characters beginning with a digit.
      Note: Numbers are not atoms yet.

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.8 No
      Since this is only two S-expressions not enclosed by parentheses. The first one is a list containing two atoms and the
       second one is an atom.

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.17 Yes
        Because it is a collection of zero S-expressions enclosed by parentheses. This special S- expression is called the null-list.

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.23 ( (HOTDOGS) ) ----Read as: " The list of the list composed of the atom HOTDOGS."
        Because ( (HOTDOGS) ) is the first S-expression of this non-null list.

1.24 ( ( (HOTDOGS) ) )

1.25 (HOTDOGS)

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

1.27 (X Y Z)

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.37 ( (MAYONNAISE AND) PEANUT BUTTER AND JELLY)
        Because CONS sticks any S-expression onto the front of the list.

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

1.39 ( CONS S L) takes two arguments: the first one S, is any S-expression. The second one L, is any list.

1.40 ( (A B (C) ) )
        Since (  ) is a list.

1.41 ( A )

1.42 No answer
        Since the second argument L must be a list

1.43 No answer
         why? See
Principle No. 3

1.44 (A B)

1.45 (A C D)

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.54 False
        See
Principle No.2

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.6 We did not expect you to know this, but we wanted you to realize that you are still missing some necessary relationships.
       Go on to the next question. Good luck.

2.7 True
      The function (ISLAT L) where L is (BACON AND EGGS) has the value T -- true—  because L is a LAT.

2.8 We don’t expect you to know this one either. The answer is arrived at through asking the questions of (ISLAT L).
      HINT: Write down the function (ISLAT L) and refer to it for the next group of questions.

2.9 (NULL L)
       Note: “(COND” is only a necessary stem that you will have to learn to live with.
       Similarly “(DEFUN” is the necessary part of the scenery, but for your purposes, it is as useful as a screen door on a
       submarine sandwich.

2.10 (NULL L) asks if the argument L is the null list. If it is, then the value of the function is T. If it is not then we ask the next
       question. In this case, L is not the null list, so we ask the next question.

2.11 (ATOM (CAR L) )

2.12 (ATOM (CAR L) ) asks if the first S-expression of the list L is an atom. If (CAR L) is an  atom, then we want to know if
       the rest of L is also composed only of atoms. If (CAR L) is not an atom, then we ask the next question. In this case, (CAR
       L) is an atom, so the value of the function is (ISLAT (CDR L) ).

2.13 (ISLAT (CDR L) ) finds out if the rest of the list L is composed only of atoms by referring us back to the original function,
       but now with a new argument.

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

2.15 (NULL L)

2.16 (NULL L) asks if the argument L is the null list. If it is, then the value of the function is T. If it is not then we ask the next
       question. In this case, L is not the null list, so we ask the next question.

2.17 (ATOM (CAR L) )

2.18 (ATOM (CAR L) ) asks if (CAR L) is an atom. If it is an atom, then the value of the function is (ISLAT (CDR L) ). If it is
       not an atom, then we ask the next question. In this case, (CAR L) is an atom. So we to find out if the rest of the  list L is
       composed of only atoms.

2.19 (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 this time with the argument (CDR L) which is (EGGS)

2.20 (NULL L)

2.21 (NULL L) asks if the argument L is the null list. If it is, then the value of the function is T--True. If it is not then we ask the
       next question. In this case, L is not the null list, so we ask the next question.

2.22 (ATOM (CAR L) )

2.23 (ATOM (CAR L) ) asks if (CAR L) is an atom. If it is then the value of the function is (ISLAT (CDR L) ). If (CAR L) is
       not an atom, then ask the next question. In this case, (CAR L) is an atom, so once again we look at (ISLAT (CDR L) ).

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.26 (NULL L) asks if the argument L is the null list. If it is, then the value of the function is T. If it is not then we ask the next
       question. In this case, L is not the null list, so we ask the next question. In this case, (  ) is the null list. Therefore, the value
       of the function (ISLAT L).where L is (BACON AND EGGS) is T or True.

2.27 Probably not.
        The function (ISLAT L) has a value of T if the list L is a list of atoms, where L is (BACON AND EGGS)

2.28 Here are our words:
        “ISLAT looks at each S-expression, in turn, and asks if each S-expression is an atom, until it runs out of S-expressions.
       When it runs out without encountering a list, the function’s value is T. As soon as it finds a list, the function value is F –false.
       To see how we could arrive at a value of “falsconsider the next few questions.”

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

2.30 (NULL L)

2.31 (NULL L) asks if the argument L is the null list. If it is, then the value of the function is T. If it is not then we ask the next
       question. In this case, L is not the null list, so we ask the next question.

2.32 (ATOM (CAR L) )

2.33 (ATOM (CAR L) ) asks if (CAR L) is an atom. If it is then the value of the function is (ISLAT (CDR L) ). If (CAR L) is
       not an atom, then ask the next question. In this case, (CAR L) is an atom, so we want to check if the rest of the list L is
       composed only of atoms.

2.34 (ISLAT (CDR L) ) checks to see if the rest of the list L is composed only of atoms, by referring us back to (ISLAT L)
       with L replaced by (CDR L).

2.35 (NULL L) asks if the argument L is the null list. If it is, then the value of the function is T. If it is not then we ask the next
       question. In this case, L is not the null list, so we move to the next question.

2.36 (ATOM (CAR L) )

2.37 (ATOM (CAR L) ) asks if (CAR L) is an atom. If it is then the value of the function is  (ISLAT (CDR L) ). If (CAR L) is
       not an atom, then ask the next question. In this case, (CAR L) is not an atom, so we ask the next question.

2.38 T

2.39 T asks if T is true.

2.40 Yes
        because the question T is always true!

2.41 T

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

2.43 T asks if T is true.
        If T is true --- as it always is --- then the value of the function is F --- false.

2.44 These are just the closing parentheses which match “(COND”, “(DEFUN” and “(ISLAT” at the beginning of the
       description of the function. We call these “aggravation parentheses”, and they are always put at the end of a function.

2.45 Here is one way to say it:
        “(ISLAT L) looks at each S-expression in its argument to see if it is an atom. If it runs out of S-expressions before it finds
       a list, the value of (ISLAT L) is T. if it finds a list as it did in the example (BACON (AND EGGS) ), the value of (ISLAT
       L) is F”.

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.49 The value is arrived at by asking the questions about (MEMBER A LAT).
        Hint: write down the function (MEMBER A LAT), and refer to it while you work on the next group of questions.

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

2.51 (NULL LAT) asks if the LAT is the null list. If it is, then the value of the function is F  false, since the atom MEAT was not
       found in the LAT. If it is not,then we ask the next question. In this case, it is not null, so we ask the next question.

2.52 (EQ (CAR LAT) A)

2.53 (EQ (CAR LAT) A) asks if the CAR of the LAT is the same as the atom A. if it is, then the value of the function is T. If it
       is not, then we ask the next question. In this case, it is not, so we ask the next question.

2.54 T

2.55 Yes
         T is question whose answer is always true.

2.56 Here’s ours:
        “what color is an orange?”.

2.57 Now that we know that the LAT is not null, and we know that the CAR of LAT is not the same atom as A, we want to
       find out if the atom A is somewhere in the rest of the LAT. The function does this by referring us back to the original
       function, with the argument LAT replaced by (CDR LAT).

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

2.59 (NULL LAT)
        Remember
Commandment No. 1

2.60 F – false.

2.61 Ask the next question

2.62 (EQ (CAR LAT) A).

2.63 F—false

2.64 Ask the next question.

2.65 T

2.66 T --- true

2.67 (MEMBER A (CDR LAT) ) finds out if A is a member of the CDR of the LAT, by referring us back to the original
       function.

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

2.69 (NULL LAT)

2.70 Ask the next question
        Since (NULL LAT) is false)

2.71 (EQ (CAR LAT) A)

2.72 Ask the next question

2.73 T

2.74 (MEMBER A (CDR LAT) )

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

2.76 A is MEAT and LAT is (MEAT GRAVY)

2.77 (NULL LAT)

2.78 Ask the next question.
        Since (NULL LAT) is false.

2.79 (EQ (CAR LAT) A)

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.84 T
        Because MEAT is also a member of the LAT (MASHED POTATOES AND MEAT GRAVY). Of course, you noticed
       that this is our original LAT

2.85 T
        Hint: Write down the function MEMBER and its arguments and refer to them as you go through the next bunch of
       questions.

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.97 T

2.98 T

2.99 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 (  )

2.111 Yes

2.112 F

2.113 F

2.114 F

2.115 F

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.5 It takes an atom and a LAT as its arguments and makes a new LAT with the first occurrence of the atom in the old LAT
       removed

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

3.7 (EQ (CAR LAT) A)

3.8 (CDR LAT)

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

3.10 (REMBER A (CDR LAT) )

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

3.12 (LETTUCE AND TOMATO)
        Hint: Write down the function REMBER and its arguments, and refer to them as you go Through the next sequence of
       questions.

3.13 (NULL LAT)

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

3.15 Yes
        So the value of the function is (CDR LAT). In this case, it is the list (LETTUCE AND TOMATO)

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.18 It takes an atom and a LAT as its arguments and makes a new LAT with the first occurrence of the atom in the old LAT
       removed.

3.19 First, we will compare each atom of the LAT with the atom A.
        Second, we want to build a list from left to right.

3.20 (BACON LETTUCE TOMATO)

3.21 (NULL LAT)

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

3.23 No
        Move to the next line.

3.24 T asks if T is true --- as it always is --- and the rest of the line says to recurse with A
       and (CDR LAT) where A is AND and (CDR LAT) is (LETTUCE AND TOMATO)

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.29 Yes

3.30 (CDR LAT) --- (TOMATO)

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.34 (BACON LETTUCE TOMATO)
        Make a copy of this function with CONS and the arguments A and LAT, so you can refer to it for the following questions.

3.35 (NULL LAT)

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

3.37 No
        Move to the next line.

3.38 CONS (CAR LAT) --- BACON --- onto the value of (REMBER A (CDR LAT) ).
        But since we don’t know the value of (REMBER A (CDR LAT) ) yet, we will have to find this value before we can
       CONS (CAR LAT) onto it.

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

3.40 No
        Move to the next line.

3.41 No
        Move to the next line.

3.42 CONS(CSR LAT)  ---LETTUCE--- onto the value of (REMBER A (CDR LAT) ).
        But since we don’t know that value, we will have to find that value before we can CONS (CAR LAT) onto our list.

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.45 Yes

3.46 (CDR LAT) – (TOMATO).

3.47 Certainly not!
        So far we know what (REMBER A LAT) is when LAT is (AND TOMATO), but we don’t yet know what it is when
       LAT is (LETTUCE AND TOMATO) or (BACON LETTUCE AND TOMATO).

3.48 Recall that we wanted to CONS LETTUCE onto the value of (REMBER A (CDR LAT)) where A was AND and (CDR
       LAT) was (AND TOMATO). Now that we have this value, which is (TOMATO), we can CONS LETTUCE onto this
       value. Reread the last 6 steps.

3.49 (LETTUCE TOMATO)

3.50 It represents the value of (REMBER A (CDR LAT) ). When A was AND, and (CDR LAT) was (AND TOMATO)

3.51 Not quite.
        So far we know what (REMBER A LAT) is when LAT is (LETTUCE AND TOMATO),But we don’t yet know what it
       is when LAT is (BACON LETTUCE AND TOMATO)

3.52 Recall that, at one time, we wanted to CONS BACON onto the value of (REMBER A (CDR LAT) ), when A was
       AND, and (CDR LAT) was (LETTUCE AND TOMATO) Now that we have this value, which is (LETTUCE
       TOMATO), we can CONS BACON onto this value

3.53 (BACON LETTUCE TOMATO)

3.54 It represents the value of (CONS (CAR LAT) (REMBER A (CDR LAT) ) ), when A   was AND and (REMBER A
       (CDR LAT) ) was (LETTUCE TOMATO)

3.55 Yes

3.56 In our words:
        “REMBER checked each atom of the LAT, one at a time to see if it was the same as the atom AND. If the CAR was not
      the same as the atom,we saved it to be CONS’d the to the final value later. When REMBER found the atom AND, it
       dropped it, and CONS’d the previous atoms onto the rest of the LAT, in reverse order.”

3.57 (BACON LETTUCE TOMATO)
        Hint: Write down the function REMBER and its arguments and refert them as you go through the next sequence of
       questions.

3.58 No

3.59 No

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

3.61 This says to refer back to the original function REMBER, but with the argument LAT replaced by (CDR LAT), and that
       after we arrived at a value for (REMBER A (CDR LAT) ) we will CONS (CAR LAT) ---BACON--- onto it.

3.62 No

3.63 No

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

3.65 This says to refer back to the original function REMBER, but with the argument LAT replaced by (CDR LAT), and that
       after we arrived at a value for (REMBER A (CDR LAT) ) we will CONS (CAR LAT) ---LETTUCE--- onto it.

3.66 No

3.67 Yes

3.68 (CDR LAT) --- (TOMATO)

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

3.70 CONS (CAR LAT) ---BACON--- onto (LETTUCE TOMATO)
        See answer #3.64 forming (BACON LETTUCE TOMATO).

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

3.72 (APPLE PLUM GRAPE BEAN)

3.73 (A C E)

3.74 (  )

3.75 (FIVE FOUR ELEVEN)

3.76 We tried the following:
        "FIRSTS takes one argument, a list. Which must either be a null list or contain one or more non null lists. It builds another
       list composed of the first S-expression of each internal list."

3.77 Believe it or not, you can probably write the following:
 
         (DEFUN FIRSTS ( L )
              (COND
              ( (NULL L)     )
              (T (CONS (FIRSTS (CDR L) ) ) )
              )
         )

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.80 Commandment No. 1

3.81 Because the last line always begin with (T.
        The reason for this clarified as more examples are considered.

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.84 Because these are matching parentheses for (COND  and the first line, and they always appear at the end of a function
       definition.

3.85 A

3.86 C or E

3.87 B or D or F

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.91 Nothing yet.
        We are still missing one important ingredient in our recipe. The line (NULL L)     ) needs a value for the case where L is
       the null list. We can,however proceed without it for now.

3.92 No
        So move to the next line.

3.93 It saves (CAR (CAR L) ) to CONS it onto (FIRSTS (CDR L) ), when it finds that value. To find (FIRSTS (CDR L) ),
       we recurse to the original function   (FIRSTS L), with the new argument (CDR L)

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.98 Yes

3.99 There is no value, something is missing.

3.100 A list
          Remember
Principle No. 3 -- see chapter 1.

3.101 Since the final value must be a list, we cannot use T or F as our final value, so how about (  )?

3.102 (A C E)

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.106 (A B C D E F G D H)

3.107 In our own words:
          "It needs three arguments: the atoms OLD and NEW and a LAT. INERTR builds a LAT with NEW inserted to the right
        of the first occurrence of OLD."

3.108
            (DEFUN INSERTR  (OLD NEW LAT)
                      (COND
                      ( (NULL LAT)  (  ) )
                      ( (EQ (CAR LAT) OLD) (CDR LAT) )
                      (T (CONS  (CAR LAT) (INSERTR OLD NEW (CDR LAT) ) ) )
                      )
             )

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.116
            (DEFUN INSERTR  (OLD NEW LAT)
                      (COND
                      ( (NULL LAT)  (  ) )
                      ( (EQ (CAR LAT) OLD) (CONS OLD (CONS NEW  (CDR LAT) ) ) )
                      (T (CONS (CAR LAT) (INSERTR OLD NEW (CDR LAT) ) ) )
                      )
             )
 
Because that, where OLD is FUDGE, NEW is TOPPING and LAT is (ICE CREAM WITH FUDGE FOR DESSERT), the value of the function is (ICE CREAM WITH FUDGE TOPPING FOR DESSERT). If you got this one right, have one.

3.117  This much is trivial ---- right?

            (DEFUN INSERTL  (OLD NEW LAT)
                      (COND
                      ( (NULL LAT)  (  ) )
                      ( (EQ (CAR LAT) OLD) (CONS NEW CONS (CAR LAT) (CDR LAT) ) ) )
                      (T (CONS (CAR LAT) (INSERTL OLD NEW (CDR LAT) ) ) )
                      )
             )

3.118  For example this line could have been:
           ( (EQ (CAR LAT) OLD) (CONS NEW (CONS OLD  (CDR LAT) ) ) )
           or even better like this: ( (EQ (CAR LAT) OLD) (CONS NEW LAT) ), since (CONS OLD (CDR LAT) ) is same as
        LAT.

3.119  Obviously
            (DEFUN  SUBST (OLD NEW LAT)
                       (COND
                        ( (NULL LAT)  (  ) )
                        ( (EQ (CAR LAT) OLD) (CONS NEW (CDR LAT) ) )
                        (T (CONS (CAR LAT) (SUBST OLD NEW (CDR LAT) ) ) )
                         )
             )

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