The Little Schemer - 4th Edition
Daniel P. Friedman, Matthias Felleisen, Duane Bibby
Format: PDF / Kindle (mobi) / ePub
The notion that "thinking about computing is one of the most exciting things the human mind can do" sets both The Little Schemer (formerly known as The Little LISPer) and its new companion volume, The Seasoned Schemer, apart from other books on LISP. The authors' enthusiasm for their subject is compelling as they present abstract concepts in a humorous and easy-to-grasp fashion. Together, these books will open new doors of thought to anyone who wants to find out what computing is really about. The Little Schemer introduces computing as an extension of arithmetic and algebra; things that everyone studies in grade school and high school. It introduces programs as recursive functions and briefly discusses the limits of what computers can do. The authors use the programming language Scheme, and interesting foods to illustrate these abstract ideas. The Seasoned Schemer informs the reader about additional dimensions of computing: functions as values, change of state, and exceptional cases. The Little LISPer has been a popular introduction to LISP for many years. It had appeared in French and Japanese. The Little Schemer and The Seasoned Schemer are worthy successors and will prove equally popular as textbooks for Scheme courses as well as companion texts for any complete introductory course in Computer Science.
on two tups. If you recur on one tup how many questions do you have to ask? Two, they are (num tup) and else. When recurring on two tups, how many questions need to be asked about the tups? Four: if the first tup is empty or non-empty, and if the second tup is empty or non-empty. Do you mean the questions (and (null'? tup1) (num tup2» (num tup1) (num tup2) and else Yes. Can the first tup be 0 at the same time as the second is other than 0 No, because the tups must have the same length.
82» «atom? 81) #f) «atom? 82) #f) (else (eqli8t? 81 82))))) Chapter 5 Why is the second question (atom? 81) If it is true, we know that the first argument is an atom and the second argument is a list. And why is the third question (atom? 82) By the time we ask the third question we know that the first argument is not an atom. So all we need to know in order to distinguish between the two remaining cases is whether or not the second argument is an atom. The first argument must be a list.
Commandment The Seventh Commandment Always change at least one argument while recurring. When recurring on a list of atoms, lat, use (cdr lat). When recurring on a number, n, use (sub1 n). And when recurring on a list of S-expressions, I, use (car I) and (cdr I) if neither (null? I) nor (atom? (car I)) are The true. Recur on the subparts that are of the same nature: • On the sublists of a list. • On the subexpressions of an arithmetic expression. Eighth Commandment It must be changed to be
n))) Can you write a function that is like addl What about subl (define eddl (lambda (n) (cons (quote ()) n))) (define zubl (lambda (n) (cdr n))) Is this correct? What is (zubl n) where n is Rewrite Let's see. 0 + using this representation. Has the definition of + changed? 108 No answer, but that's fine. - Recall The Law of Cdr. (define -to (lambda (n m) (cond «sero? m) n) (else (eddl (-to n (zubl m»))))) Yes and no. It changed, but only slightly. Chapter 6 Recall'at? Easy:
(length) (lambda (l) (cond (( null? I) 0) (else (add1 (length (cdr l))))))) ((lambda (length) (lambda (I) (cond (( null? I) 0) (else (add1 (length (cdr I))))))) eternity))) Close, but there are still repetitions. True. Let's get rid of them. Where should we start? Name the function that takes length as an argument and that returns a function that looks like length. ... and Again, and Again, and Again, ... 163 What's a good name for this function? How about mk-Iength for "make length"?