Simply Scheme: Alphabetical Table of Scheme Primitives Simply Scheme: Introducing Computer Science 2/e Copyright (C) 1999 MIT

# Alphabetical Table of Scheme Primitives

 `'` Abbreviation for `(quote` …`)`. `*` 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? `abs` Return the absolute value of the argument. `accumulate` Apply a combining function to all elements (see here). `align` Return a string spaced to a given width (see here). `and` (Special form) Are all of the arguments true values (i.e., not `#f`)? `appearances` Return the number of times the first argument is in the second. `append` Return a list containing the elements of the argument lists. `apply` Apply a function to the arguments in a list. `assoc` Return association list entry matching key. `before?` Does the first argument come alphabetically before the second? `begin` (Special form) Carry out a sequence of instructions (see here). `bf` Abbreviation for `butfirst`. `bl` Abbreviation for `butlast`. `boolean?` Return true if the argument is `#t` or `#f`. `butfirst` Return all but the first letter of a word, or word of a sentence. `butlast` Return all but the last letter of a word, or word of a sentence. `c...r` Combinations of `car` and `cdr` (see here). `car` Return the first element of a list. `cdr` Return all but the first element of a list. `ceiling` Round a number up to the nearest integer. `children` Return a list of the children of a tree node. `close-all-ports` Close all open input and output ports. `close-input-port` Close an input port. `close-output-port` Close an output port. `cond` (Special form) Choose among several alternatives (see here). `cons` Prepend an element to a list. `cos` Return the cosine of a number (from trigonometry). `count` Return the number of letters in a word or number of words in a sentence. `datum` Return the datum of a tree node. `define` (Special form) Create a global name (for a procedure or other value). `display` Print the argument without starting a new line. `empty?` Is the argument empty, i.e., the empty word `""` or the empty sentence `()`? `eof-object?` Is the argument an end-of-file object? `equal?` Are the two arguments the same thing? `error` Print an error message and return to the Scheme prompt. `even?` Is the argument an even integer? `every` Apply a function to each element of a word or sentence (see here). `expt` Raise the first argument to the power of the second. `filter` Select a subset of a list (see here). `first` Return first letter of a word, or first word of a sentence. `floor` Round a number down to the nearest integer. `for-each` Perform a computation for each element of a list. `if` (Special form) Choose between two alternatives (see here). `integer?` Is the argument an integer? `item` Return the \$n\$th letter of a word, or \$n\$th word of a sentence. `keep` Select a subset of a word or sentence (see here). `lambda` (Special form) Create a new procedure (see Chapter \lambchop). `last` Return last letter of a word, or last word of a sentence. `length` Return the number of elements in a list. `let` (Special form) Give temporary names to values (see here). `list` Return a list containing the arguments. `list->vector` Return a vector with the same elements as the list. `list-ref` Select an element from a list (counting from zero). `list?` Is the argument a list? `load` Read a program file into Scheme. `log` Return the logarithm of a number. `make-node` Create a new node of a tree. `make-vector` Create a new vector of the given length. `map` Apply a function to each element of a list (see here). `max` Return the largest of the arguments. `member` Return subset of a list starting with selected element, or `#f`. `member?` Is the first argument an element of the second? (see here). `min` Return the smallest of the arguments. `newline` Go to a new line of printing. `not` Return `#t` if argument is `#f`; return `#f` otherwise. `null?` Is the argument the empty list? `number?` Is the argument a number? `odd?` Is the argument an odd integer? `open-input-file` Open a file for reading, return a port. `open-output-file` Open a file for writing, return a port. `or` (Special form) Are any of the arguments true values (i.e., not `#f`)? `procedure?` Is the argument a procedure? `quote` (Special form) Return the argument, unevaluated (see here). `quotient` Divide numbers, but round down to integer. `random` Return a random number ≥ 0 and smaller than the argument. `read` Read an expression from the keyboard (or a file). `read-line` Read a line from the keyboard (or a file), returning a sentence. `read-string` Read a line from the keyboard (or a file), returning a string. `reduce` Apply a combining function to all elements of list (see here). `remainder` Return the remainder from dividing the first number by the second. `repeated` Return the function described by f(f(⋅⋅⋅(f(x)))) (see here). `round` Round a number to the nearest integer. `se` Abbreviation for `sentence`. `sentence` Join the arguments together into a big sentence. `sentence?` Is the argument a sentence? `show` Print the argument and start a new line. `show-line` Show the argument sentence without surrounding parentheses. `sin` Return the sine of a number (from trigonometry). `sqrt` Return the square root of a number. `square` Not a primitive! `(define (square x) (* x x))` `trace` Report on all future invocations of a procedure. `untrace` Undo the effect of `trace`. `vector` Create a vector with the arguments as elements. `vector->list` Return a list with the same elements as the vector. `vector-length` Return the number of elements in a vector. `vector-ref` Return an element of a vector (counting from zero). `vector-set!` Replace an element in a vector. `vector?` Is the argument a vector? `vowel?` Not a primitive! `(define (vowel? x) (member? x '(a e i o u)))` `word` Joins words into one big word. `word?` Is the argument a word? (Note: numbers are words.) `write` Print the argument in machine-readable form (see here).
Brian Harvey, `bh@cs.berkeley.edu`