“[D]iscover algorithms for yourself”—The Little
Schemer
(mentioned recently by
shokwave) is this, but for
things defined in terms of themselves (i.e., recursive data structures and
recursive functions).
It is a
programmed
text, which means you read it with a card in your hand
covering up part of the page. The book asks a question,
then you come up with an answer, then you move the card and
check your answer. The authors play around with this format
a bit, sometimes asking you questions that you have to make
an educated guess at, or asking you questions that you have
to think about long enough to realize that you don’t yet
know how to answer them.
From the preface:
What You Need to Know to Read This Book
The reader must be comfortable reading English,
recognizing numbers, and counting.
The notational system the book uses is (a small but powerful
subset of) the
Lisp
dialect
Scheme.
In the opening pages, you learn what atoms and lists are.
By page 21 you have seen how to write a recursive function
that tells you whether every item in a list is an atom.
Later you write recursive functions on lists of lists (i.e.,
tree structures) and define Peano
arithmetic,
and by the end of the book you have written a Scheme
interpreter (a function that can evaluate any other
function).
Recursive functions were mind-benders to me at first. Now,
thanks to The Little Schemer, I eat them for breakfast.
To check your understanding, you can type this stuff into a
Scheme interpreter (or a Lisp one—the book has footnotes
showing what you’ll need to change), but it’s possible
to go through it with nothing but a pencil and paper. (I
went through most of it just typing my answers into a text
editor.)
The authors have honed the book (through several editions)
with actual students, and it shows. Several times while
reading it I thought, “Why are they asking me this
again?”, then it turned out the question they were asking
required me to make a conceptual leap not required by the
similar question from a previous page.
Disclosure: I have not yet gone through the last couple
chapters
frame by
frame. (Edit: I finally got back to the book and finished it in June
2013.)
(I have, however, written a Lisp interpreter [with
lexical
scope,
the scoping style used by Scheme and other modern
Lisps].)
| This space reserved for |
| |
| |
| |
| JELLY STAINS! |
As written, that wouldn’t actually upvote anything; it would evaluate the variables upvote and arundel-post and build a cons cell containing them, which would serve as the value of the expression. Since we’re talking scheme, functions called for their side-effects customarily end with an exclamation mark. I would write something like this:
(upvote! arundel-post)
Here endeth the extreme pedantry! And now, before I forget, I’m going to go upvote the post instead of just talking about upvoting it.
“[D]iscover algorithms for yourself”—The Little Schemer (mentioned recently by shokwave) is this, but for things defined in terms of themselves (i.e., recursive data structures and recursive functions). It is a programmed text, which means you read it with a card in your hand covering up part of the page. The book asks a question, then you come up with an answer, then you move the card and check your answer. The authors play around with this format a bit, sometimes asking you questions that you have to make an educated guess at, or asking you questions that you have to think about long enough to realize that you don’t yet know how to answer them.
From the preface:
The notational system the book uses is (a small but powerful subset of) the Lisp dialect Scheme. In the opening pages, you learn what atoms and lists are. By page 21 you have seen how to write a recursive function that tells you whether every item in a list is an atom. Later you write recursive functions on lists of lists (i.e., tree structures) and define Peano arithmetic, and by the end of the book you have written a Scheme interpreter (a function that can evaluate any other function).
Recursive functions were mind-benders to me at first. Now, thanks to The Little Schemer, I eat them for breakfast.
To check your understanding, you can type this stuff into a Scheme interpreter (or a Lisp one—the book has footnotes showing what you’ll need to change), but it’s possible to go through it with nothing but a pencil and paper. (I went through most of it just typing my answers into a text editor.)
The authors have honed the book (through several editions) with actual students, and it shows. Several times while reading it I thought, “Why are they asking me this again?”, then it turned out the question they were asking required me to make a conceptual leap not required by the similar question from a previous page.
Disclosure: I have not yet gone through the last couple chapters frame by frame. (Edit: I finally got back to the book and finished it in June 2013.) (I have, however, written a Lisp interpreter [with lexical scope, the scoping style used by Scheme and other modern Lisps].)
(cons upvote arundel-post)
As written, that wouldn’t actually upvote anything; it would evaluate the variables
upvote
andarundel-post
and build a cons cell containing them, which would serve as the value of the expression. Since we’re talking scheme, functions called for their side-effects customarily end with an exclamation mark. I would write something like this:Here endeth the extreme pedantry! And now, before I forget, I’m going to go upvote the post instead of just talking about upvoting it.
So, when the Little Schemer told me to cons some cake onto my face...
I get to have my cake and eat it too?