RE: books on programming

Date view Thread view Subject view Author view

From: Mark Day (markday@cisco.com)
Date: Sun Jan 14 2001 - 20:57:28 PST


> any chance of an excerpt ?

OK, but these excerpts are from The Little Lisper, which I have on my shelf,
and which has been replaced by The Little Schemer.

The following gives at least a flavor. Note that these are much easier to
understand when laid out well with good typography, as they are in the book
and aren't in this email.

--Mark

** From chapter 1, "Toys":

Is it true that this is an atom?
atom

 Yes, because atom is a string of characters beginning with the letter a.

Is it true that this is an atom?
turkey

 Yes, because turkey is a string of characters beginning with a letter.

Is it true that this is an atom?
1492

 Yes, since 1492 is a string of characters beginning with a digit.

** From chapter 7, "Shadows":

Since aexp is known to be an arithmetic expression, could we have written
numbered? in a simpler way?

 Yes:
 (define numbered?
  (lambda (aexp)
    (cond
      [(atom? aexp) (number? aexp)]
      [t (and
            (numbered? (car aexp))
            (numbered? (car (cdr (cdr aexp)))))])))

Why can we simplify?

 Because we know we've got the function right.

What is (value u) where u is 13

 13

(value x) where x is (1 + 3)

 4

(value y) where y is (1 + (3 ^ 4))

 82

(value z) where z is cookie

 No answer.

** From Chapter 9, "Lambda the Ultimate":

Why may we do this?

 Because it is safe to name the expression (lambda (recur) ...)

Why is it safe to name (lambda (recur) ...)

 Because all the variables are explicit arguments to M, or they are
primitives.

Write Mrember-curry without using function-maker. Hint: use the most recent
definition of function-maker in two different places.

 From (define Mrember-curry (function-maker function-maker))

 we get

 (define Mrember-curry
  ((lambda (future)
    (M (lambda (arg)
      ((future future) arg))))
   (lambda (future)
    (M (lambda (arg)
       ((future future) arg))))))

Do you need a rest?

 Yes? Then take one.

Abstract the definition of Mrember-curry by abstracting away the association
with the program M. Hint: wrap a (lambda (M) ...) around the definition.

 We call this function Y.

 (define Y
   (lambda (M)
     ((lambda (future)
        (M (lambda (arg)
             ((future future) arg))))
      (lambda (future)
        (M (lambda (arg)
             ((future future) arg)))))))


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Sun Jan 14 2001 - 20:57:39 PST