Simply Scheme Support Definitions
Simply Scheme Support Definitions
Ported by Danny Yoo (email@example.com)
This collection adds a new _Simply Scheme_ teaching language into
DrScheme called _Simply Scheme_ and is used in the textbook:
Simply Scheme / Introducing Computer Science, Second Edition
Brian Harvey and Matthew Wright
MIT Press, 1999
The original source of these programs can be found from the FTP site:
These definitions can also be required by using:
(require (planet "simply-scheme.ss" ("dyoo" "simply-scheme.plt")))
The definitions in _simply-scheme.ss_ should correspond to those in
simply.scm version 3.13 (8/11.98).
One distinguishing feature of this language is the abstraction of
numbers. Strings are also treated as numbers by the arithmetic
(+ "40" 2) ==> 42
This can be enabled or disabled by using _strings-are-numbers_:
> (strings-are-numbers bool)
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.
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.)
Table of Scheme Primitives by Category
(Primitives with a '*' are not part of standard Scheme)
Words and Sentences
+, -, *, /
<, <=, =, >, >=
True and False
Input / Output
Files and Ports
Alphabetical Table of Scheme Primitives
Abbreviation for (quote ...)
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.
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.
(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.
Not a primitive! (define (square x) (* x x)).
Report on all further invocations of a procedure.
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?
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.
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