What is the difference between [ ] and ( ) brackets in Racket (lisp programming language)?

According to the Racket documentation, there is no difference — there is only a convention to use [ and ] for cond clauses (and use your judgement for the rest, as far as I understand): The use of square brackets for cond clauses is a convention. In Racket, parentheses and square brackets are actually interchangeable, … Read more

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

Dr Racket problems with SICP

Even if possible, such redefinitions are not something that you should do without really understanding how the system will react to this. For example, if you redefine +, will any other code break? The answer to that in Racket’s case is “no” — but this is because you don’t really get to redefine +: instead, … Read more

Is there an equivalent to Lisp’s “runtime” primitive in Scheme?

current-milliseconds is a function that returns the current millisecond count from the system, but it might decrease. current-inexact-milliseconds is similar, but returns a guaranteed-to-increase floating point number. There are also a bunch of similar functions that you can find on that page, but if all you need is to time a certain function, then just … Read more

Why is one-armed “if” missing from Racket?

Rationale The one-armed variant of if was removed from Racket to prevent bugs. In functional code one always uses the two-armed variant of if. (if test expr-on-true expr-on-false) Forgetting the second arm expr-on-false would not lead to a syntax-error, but to a runtime error (the expression would return #<void>). To prevent these often occurring bugs … 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

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

Collection of Great Applications and Programs using Macros

Culpepper & Felleisen, Fortifying Macros, ICFP 2010 Culpepper, Tobin-Hochstadt and Felleisen, Advanced Macrology and the Implementation of Typed Scheme, Scheme Workshop 2007 Flatt, Findler, Felleisen, Scheme with Classes, Mixins, and Traits, APLAS 2006 Herman, Meunier, Improving the Static Analysis of Embedded Languages via Partial Evaluation, ICFP 2004