How do I handle an unspecified number of parameters in Scheme?

In Scheme you can use the dot notation for declaring a procedure that receives a variable number of arguments (also known as varargs or variadic function): (define (procedure . args) …) Inside procedure, args will be a list with the zero or more arguments passed; call it like this: (procedure “a” “b” “c”) As pointed … Read more

Separate Namespaces for Functions and Variables in Common Lisp versus Scheme

The two different approaches have names: Lisp-1 and Lisp-2. A Lisp-1 has a single namespace for both variables and functions (as in Scheme) while a Lisp-2 has separate namespaces for variables and functions (as in Common Lisp). I mention this because you may not be aware of the terminology since you didn’t refer to it … 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

What’s the point of lambda in scheme?

A let is a lambda. E.g. (let ((x 1)) body) can be translated into ((lambda (x) body) 1) Furthermore, in Scheme all control and environment structures can be represented by lambda expressions and applications of lambdas. So, lambda is strictly more powerful than let and forms the basis of many of the interesting constructs found … 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

scheme continuations for dummies

Forget about call/cc for a moment. Every expression/statement, in any programming language, has a continuation – which is, what you do with the result. In C, for example, x = (1 + (2 * 3)); printf (“Done”); has the continuation of the math assignment being printf(…); the continuation of (2 * 3) is ‘add 1; … Read more

tech