On this page:
2.1 Introduction
2.2 Built-In
nil
inc
dec
the-empty-stream
cons-stream
stream-null?
runtime
random
amb

2 SICP Language

 #lang sicp package: sicp

2.1 Introduction

The programs in the book are written in (a subset of) the programming language Scheme. As the years have passed the programming language Scheme has evolved. The language #lang sicp provides you with a version of R5RS (the fifth revision of Scheme) changed slightly in order for programs in SICP to run as is.

To use the sicp language simply use #lang sicp as the first line of your program. If you need to use Racket libraries, then use #%require. R5RS has no require to avoid breaking programs that use the name require. #%require is therefore used instead.

2.2 Built-In

value

nil : null?

An alias for '().

procedure

(inc x)  number?

  x : number?
Returns (+ x 1).

procedure

(dec x)  number?

  x : number?
Returns (- x 1).

value

the-empty-stream : stream?

The null/empty stream.

syntax

(cons-stream first-expr rest-expr)

Produces a stream

procedure

(stream-null? s)  boolean?

  s : stream?
Returns #t if s is the-empty-stream, #f otherwise.

procedure

(runtime)  natural-number/c

Returns the current time measured as the number of seconds passed since a fixed beginning.

procedure

(random n)  real?

  n : positive?
Returns an random integer between 0 and n-1 (inclusive) if n is an exact integer, otherwise returns a random inexact number between 0 and n (exclusive).

syntax

(amb expr ...)

The amb operator.

Additionally, true, false, identity, and error are provided from Racket.