1 Introduction
2 Quick Start
3 Table of Scheme Primitives by Category
3.1 Words and Sentences
3.2 Lists
3.3 Trees
3.4 Arithmetic
3.5 True and False
3.6 Variables
3.7 Vectors
3.8 Procedures
3.9 Higher-Order Procedures
3.10 Control
3.11 Input / Output
3.12 Files and Ports
4 Alphabetical Listing of Scheme Primitives
*
+
-
/
<
<=
=
>
>=
abs
accumulate
align
and
appearances
append
apply
assoc
before?
begin
bf
bl
boolean?
butfirst
butlast
c...r
car
cdr
ceiling
children
close-all-ports
close-input-port
close-output-port
cond
cons
cos
count
datum
define
display
empty?
eof-object?
equal?
error
even?
every
expt
filter
first
floor
for-each
if
integer?
item
keep
lambda
last
length
let
list
list->vector
list-ref
list?
load
log
make-node
make-vector
map
max
member
member?
min
newline
not
null?
number?
odd?
open-input-file
open-output-file
or
procedure?
quote
quotient
random
read
read-line
read-string
reduce
remainder
repeated
round
se
sentence
sentence?
show
show-line
sin
sqrt
square
trace
untrace
vector
vector->list
vector-length
vector-ref
vector-set!
vector?
vowel?
word
word?
write
5 Deviations from plain racket
5.1 Strings are numbers
strings-are-numbers
6 Differences from the book and things to fix
7 Thanks!
Version: 5.1.1

Simply Scheme Support Definitions

Danny Yoo <dyoo@cs.wpi.edu>

1 Introduction

This library adds a Simply Scheme teaching language into DrRacket; the language is used in the textbook:

Simply Scheme / Introducing Computer Science, Second Edition

Brian Harvey and Matthew Wright

MIT Press, 1999

http://www.cs.berkeley.edu/~bh/ss-toc2.html

The original source of these programs can be found from the FTP site at ftp://ftp.cs.berkeley.edu/pub/scheme. The definitions in this library should correspond to those in "simply.scm" version 3.13 (8/11.98).

2 Quick Start

Although we use these definitions from switching the DrRacket language level to Simply Scheme, this library can also be easily used as a #lang language.

For example, if your DrRacket language level has been set to Determine langauge from source, then the following example should run without any trouble:

#lang planet dyoo/simply-scheme:2
(se (butlast (bf "this"))
    "world")

3 Table of Scheme Primitives by Category

(Primitives with a ’*’ are not part of standard Scheme)

3.1 Words and Sentences

3.2 Lists

3.3 Trees

3.4 Arithmetic

3.5 True and False

3.6 Variables

3.7 Vectors

3.8 Procedures

3.9 Higher-Order Procedures

3.10 Control

3.11 Input / Output

3.12 Files and Ports

4 Alphabetical Listing of Scheme Primitives

 (require (planet dyoo/simply-scheme:2:1))

multiply numbers

add numbers

subtract numbers

divide numbers

Is the first argument less than the second?

Is the first argument less than or equal to the second?

Are two numbers equal? (Like equal? but works only for numbers)

Is the first argument greater than the second?

Is the first argument greater than or equal to the second?

Return the absolute value of the argument.

Apply a combining function to all the elements.

Return a string spaced to a given width.

(Special form) Are all of the arugments true values (i.e., not #f)?

Return the number of times the first argument is in the second.

Return a list containing the elements of the argument lists.

Apply a function to the arguments in a list.

Return association list entry matching key.

Does the first argument come alphabetically before the second?

(Special form) Carry out a sequence of instructions.

Abbreviation for butfirst.

Abbreviation for butlast.

Return true if the argument is #t or #f.

Return all but the first letter of a word, or word of a sentence.

Return all but the last letter of a word, or word of a sentence.

c...r
Combinations of car and cdr.

Return the first element of a list.

Return all but the first element of a list.

Round a number up to the nearest integer.

Return a list of the children of a tree node.

Close all open input and output ports.

Close an input port.

Close an output port.

(Special form) Choose among several alternatives.

Prepend an element to a list.

Return the cosine of a number (from trigonometry).

Return the number of letters in a word or number of words in a sentence.

Return the datum of a tree node.

(Special form) Create a global name (for a procedure or other value).

Print the argument without starting a new line.

Is the arugment empty, i.e., the empty word "" or the empty sentence ()?

Is the argument an end-of-file object?

Are the two arguments the same thing?

Print an error message and return to the Scheme prompt.

Is the argument an even integer?

Apply a function to each element of a word or sentence.

Raise the first argument to the power of the second.

Select a subset of a list.

Return first letter of a word, or first word of a sentence.

Round a number down to the nearest integer.

Perform a computation for each element of a list.

(Special form) Choose between two alternatives.

Is the argument an integer?

Return the nth letter of a word, or nth word of a sentence.

Select a subset of a word or sentence.

(special form) Create a new procedure.

Return last letter of a word, or last word of a sentence.

Return the number of elements in a list.

(Special form) Give temporary names to values.

Return a list containing the arguments.

Return a vector with the same elements as the list.

Select an element from a list (counting from zero).

Is the argument a list?

Read a program file into Scheme.

Return the logarithm of a number.

Create a new node of a tree.

Create a new vector of the given length.

Apply a function to each element of a list.

Return the largest of the arguments.

Return subset of a list starting with the selected element, or #f.

Is the first argument an element of the second?

Return the smallest of the arguments.

Go to a new line of printing.

Return #t if the argument is #f; return #f otherwise.

Is the argument the empty list?

Is the argument a number?

Is the argument an odd number?

Open a file for reading, return a port.

Open a file for writing, return a port.

(Special form) Are any of the arguments true values (i.e., not #f)?

Is the argument a procedure?

(Special form) Return the argument, unevaluated.

Divide number, but round down to integer

Return a random number >= 0 and smaller than the argument

Read an expression from the keyboard (or a file).

Read a line from the keyboard (or a file), returning a sentence.

Read a line from the keyboard (or a file), returning a string.

Apply a combining function to all elements of list.

Return the remainder from dividing the first number by the second.

Return the function described by f(f(...(f(x)))).

Round a number to the nearest integer.

Abbreviation for sentence.

Join the arguments together into a big sentence.

Is the argument a sentence?

Print the argument and start a new line.

Show the argument sentence without surrounding parentheses.

Return the sine of a number (from trigonometry).

Return the square root of a number.

square
Not a primitive! (define (square x) (* x x)).

trace
Report on all further invocations of a procedure.

untrace
Undo the effects of trace.

Create a vector with the arguments as elements.

Return a list with the same elements as the vector.

Return the number of elements in a vector.

Return an element of a vector (counting from zero).

Replace an element in a vector.

Is the argument a vector?

vowel?
Not a primitive! (define (vowel? x) (member x ’(a e i o u)))

Joins words into one big word.

Is the argument a word? (Note: numbers are words.)

Print the argument in machine-readable form.

5 Deviations from plain racket

5.1 Strings are numbers

One distinguishing feature of this language is the abstraction of numbers. Strings are also treated as numbers by the arithmetic operators:
> (+ "40" 2)

42

This can be enabled or disabled by using strings-are-numbers:

If bool is set to #t, strings will be treated as numbers, and the arithmetic operators will be overloaded to work with strings. If bool is set to #f, strings will not be treated as numbers.

6 Differences from the book and things to fix

FIXME: the other helper libraries haven’t been mapped yet. (things like functions.scm would be nice to have as a library.)

I also need to improve the documentation to use Scribble features; the current work is a rush job.

7 Thanks!

Thanks to my professors at UC Berkeley, especially Brian Harvey and Dan Garcia. Yes, CS61A was the best computer science class I’ve taken.

Thanks to Reid Oda for catching a very ugly bug involving namespaces, and Matthew Flatt for telling me how to fix it. See http://list.cs.brown.edu/pipermail/plt-scheme/2007-February/016387.html.