Dr. Jozo J. Dujmović
SCHEME REFERENCE CARD
ARITHMETIC OPERATORS AND FUNCTIONS
(pair?
(null?
TESTS
(zero?
EQUIVALENCE PREDICATES
(eq?
(equal?
True if
True if
True if
True if
True if
True if
bound to the same memory location (this test of physical sameness can be implementation-dependent) True if
(+
(1+
(sub1
(-1+
(minus
(*
pi
(quotient
(remainder
(ceiling
(floor
(round
(truncate
(modulo
(lcm
LIBRARY FUNCTIONS
(abs
(sqrt
(max
(log
(sin
(cos
(tan
(asin
(acos
(atan
RELATIONAL OPERATORS
(=
RECOGNIZERS
(number?
Change the sign of
Raises
A variable initially set to 3.1415927 Integer division
Larger integer <=
The least common multiple
Absolute value of
Square root of nonnegative
Maximum of
Minimum of
The exponential of
Natural logarithm of
The trigonometric sine of
The arc cosine of
The arc tangent of
True if
True if
True if
True if
True if
True if
True if
True if
True if
True if
True if
[MT-] [M-]
“
(make-string
(string-length
(string-append
[M-] [M-]
[M-]
LOGICAL VALUES AND OPERATORS
#t #T t T ()#f#FNIL TRUE
FALSE
(not
(and
True
False
A variable that some Schemes initially set to #T A variable that some Schemes initially set to #F Negation of
(or
[(or) yields #F]
CHARACTERS
value (this test causes evaluation of expr.) True if
values
#\a #\B #\newline #\space #\tab #\TAB Characters (printable and non printable) (char->integer
(char->downcase
STRINGS
Return the lower case version of
True if
True if
True if
True if
True if
A string of characters
String containing
(define (string-copy
(string-fill!
is bound to a new copy of
Fills an existing
Convert a character to string
ASCII to decimal number conv. of
DEFINITIONS AND BINDINGS
(define
(define
(set!
(let ( (
(let* ( (
(letrec ( (
FUNCTIONS
(lambda (
(define (
(string->symbol
(symbol->string
(string->list
(list->string )
(string->number
(number->string
(string->number
Define
Define
Local bindings var1:=expr1,… and then the
application of these values to the expression1, expression2 … (the returned value is the value of the
last expression)
A version of let where variables are bound in sequence from the first to the last (different from let)
A version of let allowing for mutual recursion
(string-null?
(string=?
PAIRS AND LISTS
True if
True if
Return the given
Return the first element of pair (or the head of list) Return the second element of pair or the tail of list Empty list; both (car ‘()) and (cdr ‘()) return ‘() [M-] Combinationofupto4carandcdr(x={a|d}) Make a dotted pair (
Make a list of objects
Proper list ‘(
Anonymous function definition (lambda expression) Function definition (binding fname and
quote
abbreviated: ‘
(define
(define() Apply
(cxxxxr )
(cons
(list
‘(
‘(
(andmap ) (for-each
)
(apply ) (eval
CONTROL STRUCTURES (begin
the and return the list of resulting values Application of and to the results of map [MT-] Left-to-right application of function to list elements for side effect(s) only (the returned value is
implementation-specific)
Exec.
Evaluate all expressions and return the value of the
last expression in the sequence.
Evaluate all expressions and return the value of
(length )
(append )
(list-ref
(member ) (set-car!
Length of a list. (length
Append lists
Return a list with reversed order of elements Returns the zero-based element , assuming 0 <= index <= length-1. If index<0 it returns the car element, and if index>=length it returns ().
Returns a tail-sublist from
list, or () if .
Replaces the head of with the value of
Replaces the tail of with the value of
(vector
(
(case
(
(define v ‘#(
(make-vector
(make-vector
(vector-length
(vector-ref
(vector->list ) List to vector conversion
…………… Evaluateallexpressionsintheselectedlistand (
(else
Definition of vector (‘ is sometimes omitted) Vector having
(begin0
(if
Conditional execution: it returns the value of
(some implementations, including pcs, return ( ) ).
Conditional execution: evaluate tests and execute either the sequence of expressions following the first thatisnonnull,ortheexpressionsinthelastline.
It returns the value of the last executed expression. Else clause can be omitted (but in such a case the result of cond for all false tests is unspecified.)
Conditional execution: evaluate
(cond
(
.
lambda expr.)
Abbreviated form of function definition. Equivalent to(let ((
Function of an arbitrary number of arg’s
(case
(
Conditional execution: evaluate
[Inspect] ? TI Scheme Inspect Commands ? — display this command summary
! — reinitialize INSPECT
ctrl-A — display All environment frame bindings ctrl-B — display procedure call Backtrace
ctrl-C — display Current environment frame bindings ctrl-D — move Down to callee’s stack frame
ctrl-E — Edit variable binding
ctrl-G — Go (resume execution)
ctrl-I — evaluate one expression and Inspect the result ctrl-L — List current procedure
ctrl-M — repeat the breakpoint Message
ctrl-P — move to Parent environment’s frame
ctrl-Q — Quit (RESET to top level)
ctrl-R — Return from BREAK with a value
ctrl-S — move to Son environment’s frame
ctrl-U — move Up to caller’s stack frame
ctrl-V — eValuate one expression in current environment ctrl-W — (Where) Display current stack frame
To enter `ctrl-A’, press both `CTRL’ and `A’. [Inspect] Quit
[8] (exit)
NOTE: Some of the presented functions are implementation-dependent and may be unavailable in some Scheme implementations. Similarly, some Scheme implementations may have additional functions and features not included in this Reference Card. Features that are not available using Texas Instruments pcs are denoted by [T-], and those not available using MIT Scheme (installed on Libra) are denoted by [M-].
……………. returnstrue.Evaluateallexpressionsin (
(do ((
Initial values are bound to corresponding variables in unspecified order. If the termination test fails, the sequence of statements (the body of the loop) is executed. After the execution the do
variables are updated in unspecified order. The update is optional (can be omitted in some cases). If the termination-test is true then the termination expressions are evaluated from first to last and the last value is returned (if expressions are not specified then the returned value of do loop is the value of the
(exit) Close the transcript file and return to the level of the operating system.
INPUT AND OUTPUT
(transcript-on “
(transcript-off) (load “
(display
Open for append (create if nonexistent) and begin echoing the terminal interaction to
Read and evaluate the contents of
Display the value of a single expression (in the case of pcs the cursor remains in the same line).
Same as (display “”)
*the-non-printing-object*
(define inport (open-input-file “fname1”))
(define outport (open-output-file “fname2”)) files named “fname1” and “fname2” respectively
(read inport)
(display
(writeln
(writeln (eval (read))) (display (eval (read))) (write
(pp
Scan and return next lexical element from input port Append the output string to file defined by outport Close input file related to
Print a sequence of expressions using display followed by a newline [M-] Read-evaluate-print sequence
Read-evaluate-print sequence
Write expression in machine-readable form, e.g. strings have double quotes (display and writeln use the human-readable form)
Pretty print the specified procedure (in the case of
pcs it must be preceded by setting the debug mode)
(define (WL lst)
(cond ((null? lst) (display “”))
(else (display (car lst)) (display ” “) (WL (cdr lst)))))
(define W (lambda lst (WL lst)))
INTERNALS
scheme.ini patch.pcs
(edwin)
PCS-DEGUB-MODE
(set! PCS-DEBUG-MODE true)
Display of a sequence of arguments (W
A file in the current working directory that is loaded and executed after the start of pcs (TI PC Scheme)
A file in the Scheme home directory that is loaded and executed after the start of pcs (TI PC Scheme).
It is used to customize the initialization of Scheme. Invoke the pcs EDWIN editor
An environmental pcs variable that must be set to
#T to enable full tracing, inspecting, and pp
Definition of input and output ports associated with
Display of list elements (in cases without writeln)