Little Schemer and Racket

DrRacket is the (r)evolution of DrScheme; DrRacket will work perfectly for the exercises in “The Little Schemer”. Just don’t forget to: In the Language dialog, choose “Use the language declared in the source” Write #lang racket at the top of each file you create Implement the atom? predicate in each file as explained at the … Read more

How does the yin-yang puzzle work?

Understanding Scheme I think at least half of the problem with understanding this puzzle is the Scheme syntax, which most are not familiar with. First of all, I personally find the call/cc x to be harder to comprehend than the equivalent alternative, x get/cc. It still calls x, passing it the current continuation, but somehow … Read more

Commenting code in Scheme

All three of the forms you mention are single-line comments. The double-semicolon may have originally arisen as a cue in Dorai Sitaram’s SLaTeX typesetting package that the comment was to be typeset as ordinary text, rather than as program text. Scheme also has multi-line comments. In particular, it appears that R6RS, like Racket, allows the … Read more

What exactly is a “continuation prompt?”

What is a prompt, conceptually? Scheme in general has the idea of continuations, but Racket extends this with the idea of delimited continuations. The idea of a continuation is that it captures the remaining computation left to be evaluated. I will not attempt to explain continuations in general, since that is outside the scope of … Read more

Y combinator discussion in “The Little Schemer”

Great question. For the benefit of those without a functioning DrRacket installation (myself included) I’ll try to answer it. First, let’s use some sane (short) variable names, easily trackable by a human eye/mind: ((lambda (h) ; A. (h h)) ; apply h to h (lambda (g) (lambda (lst) (if (null? lst) 0 (add1 ((g g) … Read more

Help understanding Continuations in Scheme

Try something simpler to see how this works. For example, here’s a version of a list-sum function that receives a continuation argument (which is often called k): (define (list-sum l k) (if (null? l) ??? (list-sum (cdr l) ???))) The basic pattern is there, and the missing parts are where the interesting things happen. The … Read more