Fundamentals of Computer Science I: Media Computing (CS151.01 2008S)

Scheme Procedures A-Z (and Beyond)


Symbols

(= num1 num2)
Standard numeric procedure. Determines if num1 is equal to num2
(< num1 num2 ...numn)
Standard numeric procedure. Determines if num1 is strictly less than num2, and num2 is strictly less than num3 and so forth.
(<= num1 num2 ...numn)
Standard numeric procedure. Determines if num1 is less than or equal to num2, and num2 is less than or equal to num3 and so forth.
(> num1 num2 ...numn)
Standard numeric procedure. Determines if num1 is strictly greater than num2, and num2 is strictly greater than num3 and so forth.
(>= num1 num2 ...numn)
Standard numeric procedure. Determines if num1 is greater than or equal to num2, and num2 is greater than or equal to num3 and so forth.

A

(and exp1 exp2 ... expn)
Standard keyword. Evaluate each expression in turn. If any of those values is false, return false. Otherwise, return the value of the last expression.

C

(car lst)
Standard list procedure. Get the first element of lst.
(cdr lst)
Standard list procedure. Get a list the same as lst but without the first element.
(char? val)
Standard Character Predicate. Determine if val is a character.
(char->integer ch)
Standard Character Procedure. Get ch's position in the collating sequence.
(char<? ch1 ch2)
Standard Character Comparator. Determine if ch1 precedes ch2 in the collating sequence. Both ch1 and ch2 must be characters.
(char<=? ch1 ch2)
Standard Character Comparator. Determine if ch1 equals ch2 or if ch1 precedes ch2 in the collating sequence. Both ch1 and ch2 must be characters.
(char=? ch1 ch2)
Standard Character Comparator. Determine if ch1 and ch2 are the same. Both ch1 and ch2 must be characters.
(char>=? ch1 ch2)
Standard Character Comparator. Determine if ch1 and ch2 are equal or if ch1 follows ch2 in the collating sequence. Both ch1 and ch2 must be characters.
(char>? ch1 ch2)
Standard Character Comparator. Determine if ch1 follows ch2 in the collating sequence. Both ch1 and ch2 must be characters.
(char-alphabetic? ch)
Standard Character Predicate. Determine if ch (which must be a character) is an alphabetic character (in English, #\a, #\b, ... #\z, #\A, #\B, ...., #\Z).
(char-ci<? ch1 ch2)
Standard Character Comparator. If both ch1 and ch2 are alphabetic characters (letters), determine if ch1 naturally precedes ch2, ignoring case. If either is not alphabetic, determine if ch1 precedes ch2 in the collating sequence. Both ch1 and ch2 must be characters.
(char-ci<=? ch1 ch2)
Standard Character Comparator. If both ch1 and ch2 are alphabetic characters (letters), determine if ch1 naturally precedes or equals ch2, ignoring case. If either is not alphabetic, determine if ch1 equals ch2 or if ch1 precedes ch2 in the collating sequence. Both ch1 and ch2 must be characters.
(char-ci=? ch1 ch2)
Standard Character Comparator. If both ch1 and ch2 are alphabetic characters (letters), determine if ch1 and ch2 represent the same letter, ignoring case. If either is not alphabetic, determine if ch1 follows ch2 in the collating sequence. Both ch1 and ch2 must be characters.
(char-ci>=? ch1 ch2)
Standard Character Comparator. If both ch1 and ch2 are alphabetic characters (letters), determine if ch1 naturally follows or equals ch2, ignoring case. If either is not alphabetic, determine if ch1 equals ch2 or if ch1 follows ch2 in the collating sequence. Both ch1 and ch2 must be characters.
(char-ci>? ch1 ch2)
Standard Character Comparator. If both ch1 and ch2 are alphabetic characters (letters), determine if ch1 naturally follows ch2, ignoring case. If either is not alphabetic, determine if ch1 follows ch2 in the collating sequence. Both ch1 and ch2 must be characters.
(char-downcase ch)
Standard Character Procedure. If ch is an upper-case character (#\A, #\B, ... #\Z, in ASCII; potentially other characters in other character sets), return the corresponding lower-case character. Otherwise, return the same character.
(char-lower-case? ch)
Standard Character Predicate. Determine if ch (which must be a character) represents a lower-case character (in English, #\a, #\b, ... #\z).
(char-upper-case? ch)
Standard Character Predicate. Determine if ch (which must be a character) represents an upper-case character (in English, #\a, #\b, ... #\z).
(char-numeric? ch)
Standard Character Predicate. Determine if ch (which must be a character) represents a digit in a number (traditionally, #\0, #\1, ... #\9, although other systems have different numeric characters).
(char-upcase ch)
Standard Character Procedure. If ch is a lower-case character (#\a, #\b, ... #\z, in ASCII; potentially other characters in other character sets), return the corresponding upper-case character (#\A for #\a, #\B for #\b, etc.). Otherwise, return the same character.
(char-whitespace? ch)
Standard Character Predicate. Determine if ch (which must be a character) represents a whitespace character, such as a space, a tab, or a newline.
(close-input-port input-port)
Standard File Procedure. Close an open input port. (It is an error to try to close something that is not an input port, or an input port that is already closed.)
(close-output-port output-port)
Standard File Procedure. Close an open output port. (It is an error to try to close something that is not an output port, or an output port that is already closed.)
(cname? val)
DrFu procedure. Checks to see if val is a string representing a color in the database of colors.
(cname->rgb string)
DrFu Procedure. Build an RGB color that corresponds to the given color name.
(color->rgb string)
DrFu Procedure. Convert any of the myriad representations of colors to a corresponding RGB color.
color-black
DrFu value. A predefined name for the color 0/0/0.
color-blue
DrFu value. A predefined name for the color 0/0/255.
color-green
DrFu value. A predefined name for the color 0/255/0.
color-red
DrFu value. A predefined name for the color 255/0/0.
color-transparent
DrFu Constant. A special color value, used only by image-compute-pixels!. If the color function returns color-transparent for a particular position, the color at that position is left unchanged.
color-white
DrFu value. A predefined name for the color 255/255/255.
(compose f g)
Traditional Higher-Order Procedure. Build a one-parameter procedure that applies g to its parameter, and then f to that result. ((compose f g) x) is the same as (f (g x)).
(cons value lst)
Standard list procedure. Create a new list by prepending value to the front of lst.
(context-get-bgcolor)
DrFu procedure. Returns GIMP's current background color (as an RGB color).
(context-get-fgcolor)
DrFu procedure. Returns GIMP's current foreground color (as an RGB color).
(context-list-colors)
DrFu Procedure. List all valid color names.
(context-get-colors str)
DrFu Procedure. List all the valid color names that contain str.

D

(display value)
Standard I/O Procedure. Print a human-readable representation of value on the screen.
(display value output-port)
Standard File Procedure. Print a human-readable representation of value on the specified port.
(drawing-bottom drawing)
DrFu Drawing Procedure. Determine the row of the bottom edge of a drawing.
(drawing-brush drawing)
DrFu Drawing Procedure. Determine the brush of an outlined simple drawing. (Does not work for compound drawings or filled simple drawings.)
(drawing-color drawing)
DrFu Drawing Procedure. Determine the color of a simple drawing. (Does not work for compound drawings.)
(drawing-filled? drawing)
DrFu Drawing Procedure. Determine if a simple drawing is filled. (Does not work for compound drawings.)
(drawing-fill drawing)
DrFu Drawing Procedure. Creates a new drawing by filling each element of drawing. Element colors are preserved. After filling, no elements of the resulting drawing are outlined.
(drawing-group drawing1 drawing2 ... drawingn)
DrFu Drawing Procedure. Create a new drawing by overlaying all of the individual drawings. Note that the drawings are stacked first to last, so drawing1 is at the bottom and drawingn is at the top.
(drawing-height drawing)
DrFu Drawing Procedure. Determine the approximate height of a drawing.
(drawing-hscale drawing factor)
DrFu Drawing Procedure. Creates a new drawing by horizontally scaling drawing by factor. Note that every part of the drawing is scaled horizontally, including the horizontal distance of each component of the drawing from the origin.
(drawing-hshift drawing amt)
DrFu Drawing Procedure. Creates a new drawing by shifting drawing horizontally by factor. If factor is positive, the drawing is shifted to the right. If factor is negative, the drawing is shifted left by the absolute value of factor.
(drawing-join drawing1 drawing2)
DrFu Drawing Procedure. Create a new drawing by overlaying drawing2 on top of drawing1.
(drawing-left drawing)
DrFu Drawing Procedure. Determine the column of the left edge of a drawing.
(drawing-outline drawing brush)
DrFu Drawing Procedure. Creates a new drawing by outlining each element in drawing with brush. Element colors are preserved. After outlining, no elements of the resulting drawing are filled.
(drawing-recolor drawing color)
DrFu Drawing Procedure. Creates a new drawing by recoloring drawing in color. Note that even if drawing contained colors, the new drawing contains only a single color.
(drawing-right drawing)
DrFu Drawing Procedure. Determine the column of the right edge of a drawing.
(drawing-scale drawing factor)
DrFu Drawing Procedure. Creates a new drawing by scaling drawing by factor. Note that every part of the drawing is scaled, including both the horizontal and vertical distance of each component of the drawing from the origin.
(drawing->image drawing width image)
DrFu Drawing Procedure. Create a new image of the specified width and height that contains the portion of drawing that fits in the rectangular region bounded on the left by 0, on the top by 0, on the right by width-1 and on the bottom by height-1.
(drawing-top drawing)
DrFu Drawing Procedure. Determine the row of the top edge of a drawing.
(drawing-type drawing)
DrFu Drawing Procedure. Determine the type of drawing represented. Returns a symbol: ellipse for ellipses and circles, rectangle for rectangles and squares, group for grouped drawings, and line for lines (not yet support).
drawing-unit-circle
DrFu Drawing Constant. A unit circle. That is, a circle with diameter 1, filled in black, centered at (0,0).
drawing-unit-square
DrFu Drawing Constant. A unit square. That is, a square with edge-length 1, filled in black, centered at (0,0).
(drawing-vscale drawing factor)
DrFu Drawing Procedure. Creates a new drawing by vertically scaling drawing by factor. Note that every part of the drawing is scaled vertically, including the vertical distance of each component of the drawing from the origin.
(drawing-vshift drawing amt)
DrFu Drawing Procedure. Creates a new drawing by shifting drawing vertically by factor. If factor is positive, the drawing is shifted downward. If factor is negative, the drawing is shifted upward by the absolute value of factor.
(drawing-width drawing)
DrFu Drawing Procedure. Determine the width of a drawing.

E

(eof-object? val)
Standard File Procedure. Determine if val is something returned by read (or read-char or peek-char) to indicate the end of input.

F

(file-exists? filename)
Standard File Procedure. Determine whether a file with the given name exists.
(foreach! func lst)
Traditional higher-order list procedure. Evaluate func on each element of the given list. Called primarily for side effects.

I

(if test consequent alternative)
Standard keyword. Evaluate test. If its value is truish (that is, anything but false), evaluate consequent and return its value. If the value of test is false (#f), evaluate and return alternative.
(image? val)
DrFu procedure. Determine if val is an image.
(image-compute-pixels! image first-col first-row last-col last-row function)
DrFu procedure. Create a portion of an image by setting each pixel in the specified region to the result of applying function to the position of the pixel. function must be a function from position to rgb-color. Warning! The current version is buggy, and may affect other pixels.
(image-get-pixel image column row)
DrFu procedure. Get the pixel at the specified posi tion in the image.
(image-height image)
DrFu procedure. Determine the height of the given image
(image-load filename)
DrFu procedure. Load an image from a file. The name of the file is a string (and, unless a named value, typically surrounded by quotation marks).
(image-new width height)
DrFu procedure. Create a new image of specified width and height.
(image-set-pixel! image column row rgb-color)
DrFu procedure. Set the pixel at the specified position to the new color.
(image-show image)
DrFu procedure. Opens a new window with the image.
(image-transform! image fun)
DrFu procedure. Transform image in place by setting each pixel to the result of applying fun to that current pixel color.
(image-transform-pixel! image column row func)
DrFu procedure. Modify the pixel at (col,row) in image by applying func to its old color and setting that pixel to the resulting color.
(image-variant image fun)
DrFu procedure. Create a new image of the same width and height as image, each of whose pixels is computed by applying fun to the color of the corresponding pixel in image.
(image-width image)
DrFu procedure. Determine the width of the given image.
(input-port? val)
Standard File Predicate. Determine if val is an open input port.
(integer->char n)
Standard Character Procedure. Get the nth character in the collating sequence.

L

(lambda (params) expression1 ... expressionn)
Standard keyword. A procedure which takes as input the names listed in params, does the computation indicated by the expressions, and returns the value of the last expression.
(list val_0 val_1 ... val_n)
Standard List Procedure. Create a new list of size n+1 of the form (val_0 val_1 ... val_n).
(list->rgb rgb-lst)
DrFu procedure.. Converts a list representation of a color of the form (r g b) into an RGB color.
(list->string char-list)
Standard String Procedure. Convert char-list (which must be a list of characters) to a string. The ith element of the list becomes the ith character in the string.
(list->vector lst)
Standard Vector Procedure. Convert lst to a vector so that the ith value in the vector is the same as the ith value in the lst.
(list-ref lst n)
Standard List Procedure. Get the nth element of lst. Note that elements are numbered starting at 0.

M

(make-string length ch)
Standard String Procedure. Create a new string of length length, containing only copies of ch.
(make-vector length val)
Standard Vector Procedure. Create a new vector of length length, containing only copies of val.
(map func lst)
Standard higher-order list procedure. Create a new list, each of whose elements is computed by applying func to the corresponding element of lst.

N

(newline)
Standard I/O Procedure. Write a newline (carriage return) to the screen.
(newline output-port)
Standard File Procedure. Write a newline (carriage return) to the specified output port.
(null? lst)
Standard list predicate. Checks if lst is the empty list.
null
Standard list constant. The empty list.
(number->string num)
Standard String Procedure. Convert num to an appropriate textual representation.

O

(o f1 f2 ... fn-1 fn)
Traditional Higher-Order Procedure. Build a one-parameter procedure that applies each f, in turn, starting with fn and working backwards. The composition, when applied to a value, x, produces the same result as (f1 (f2 (... (fn-1 (fn x))))).
(open-input-file filename)
Standard File Procedure. Open the specified file for reading. Returns an input port.
(open-output-file filename)
Standard File Procedure. Open the specified file for writing. Returns an input port.
(or exp1 exp2 ... expn)
Standard keyword. Evaluate each expression in turn. If any of those values is true, return true. Otherwise, return the value of the last expression.
(output-port? val)
Standard File Predicate. Determine if val is an open output port.

P

(peek-char)
Standard I/O Procedure. Determine the next character available from the keyboard (or other standard input port), but do not read over it.
(peek-char input-port)
Standard File Procedure. Determine the next character available on the specified port. If no characters remain, returns the end-of-file object.
(position-col pos)
DrFu procedure. Extract the column from position pos.
(position-new col row)
DrFu procedure. Build a new position that represents the point at (col,row).
(position-row pos)
DrFu procedure. Extract the row from position pos.

R

(read)
Standard I/O Procedure. Read the next value available from the keyboard.
(read input-port)
Standard File Procedure. Read the next value available on the specified port. If no characters remain, returns the end-of-file object.
(read-char)
Standard I/O Procedure. Read the next character available from the keyboard (or other standard input port).
(read-char input-port)
Standard File Procedure. Read the next character available on the specified port. If no characters remain, returns the end-of-file object.
(reverse lst)
Standard list procedure. Build a new list whose elements are the same as those of lst, but in the opposite order.
(rgb? value)
DrFu predicate. Determine if value can be interpreted as an RGB color.
(rgb->cname rgb-color)
DrFu procedure. Convert the given color to a string that names the color. Note that color names approximate RGB colors (there are many fewer names than colors).
(rgb->list rgb-color)
DrFu procedure. Convert the given color to a list of its three components.
(rgb->string rgb-color)
DrFu procedure. Convert the given RGB color to an easy-to-read string. (The string is not so easy to convert back to an RGB color.)
(rgb-bluer rgb-color)
DrFu RGB procedure. Build a bluer version of the given color.
(rgb-blue color)
DrFu procedure. Get the blue component of an RGB color.
(rgb-complement rgb-color)
DrFu RGB procedure. Compute the psuedo-complement of the given color.
(rgb-darker rgb-color)
DrFu RGB procedure. Build a darker version of the given color.
(rgb-greener rgb-color)
DrFu RGB procedure. Build a greener version of the given color.
(rgb-green color)
DrFu procedure. Get the green component of an RGB color.
(rgb-lighter rgb-color)
DrFu procedure. Build a lighter version of the given color.
(rgb-new r g b)
DrFu procedure. Build an RGB color whose red, green, and blue components are the specified values, each of which is an integer between 0 and 255 (inclusive).
(rgb-phaseshift rgb-color)
DrFu RGB procedure.Phase shift” the color by adding 128 to components less than 128 and subtracting 128 from components greater than 128.
(rgb-redder rgb-color)
DrFu RGB procedure Build a redder version of the given color.
(rgb-red color)
DrFu procedure. Get the red component of an RGB color.
(rgb-rotate rgb-color)
DrFu RGB procedure..Rotate the three components of the given color, setting the red component to the value of green, green to the value of blue, and blue to the value of red..

S

(string? val)
Standard String Predicate. Determine if val is a string.
(string->number str)
Standard String Procedure. Given a string that naturally represents a number (e.g., "23" or "3.14", or even "2.11e-5"), return the corresponding number.
(substring str start end)
Standard String Procedure. Create a new string by selecting the characters at positions start to end-1 of str. Note that substring, like string-ref uses 0-based indexing.
(string<? str1 str2)
Standard String Procedure. Determine whether str1 lexicographically precedes str2. Both str1 and str2 must be strings.
(string<=? str1 str2)
Standard String Procedure. Holds if str1 is either the same as str2 or if str1 lexicographically precedes str2. Both str1 and str2 must be strings.
(string=? str1 str2)
Standard String Procedure. Holds if str1 is the same as str2. Both str1 and str2 must be strings.
(string>=? str1 str2)
Standard String Procedure. Holds if str1 is either the same as str2 or if str1 lexicographically follows str2. Both str1 and str2 must be strings.
(string>? str1 str2)
Standard String Procedure. Determine whether str1 lexicographically follows str2. Both str1 and str2 must be strings.
(string ch_0 ch_1 ... ch_n)
Standard String Procedure. Create a new string of length n+1, by concatenating all of ch_0 through ch_n.
(string-append str_0 str_1 ... str_n)
Standard String Procedure. Create a new string of by joining together str through str_n in order. (Much like append, but for strings, rather than lists.)
(string-ci<? str1 str2)
Standard String Procedure. Determine whether str1 lexicographically precedes str2, ignoring case. Both str1 and str2 must be strings.
(string-ci<=? str1 str2)
Standard String Procedure. Holds if str1 is either the same as str2 or if str1 lexicographically precedes str2, ignoring case. Both str1 and str2 must be strings.
(string-ci=? str1 str2)
Standard String Procedure. Holds if str1 is the same as str2, ignoring case. Both str1 and str2 must be strings.
(string-ci>=? str1 str2)
Standard String Procedure. Holds if str1 is either the same as str2 or if str1 lexicographically follows str2, ignoring case. Both str1 and str2 must be strings.
(string-ci>? str1 str2)
Standard String Procedure. Determine whether str1 lexicographically follows str2, ignoring case. Both str1 and str2 must be strings.
(string-length str)
Standard String Procedure. Determine the number of characters in str.
(string-ref str pos)
Standard String Procedure. Extract the character at a specified position from a string. Like list-ref, string-ref presupposes zero-based indexing; the position is specified by the number of characters that precede it in the string. Hence, the initial character in the string is at position 0, the next at position 1, and so on.)
(string->list str)
Standard String Procedure. Convert str to a list of characters. The ith element of the list is the ith character in the string.

T

(throw message)
Standard procedure. Print the message (which is typically a string) and then stop the computation currently underway.
(throw message val1 ... valn)
Standard procedure. Print the message (which is typically a string) and all of the values. Then stop the computation currently in progress.

V

(vector val_0 val_1 ... val_n)
Standard Vector Procedure. Create a new vector of size n+1 of the form #(val_0 val_1 ... val_n).
(vector? val)
Standard Vector Predicate. Determine if val is a vector.
(vector->list vec)
Standard Vector Procedure. Convert vec to a list so that the ith value in the list is the same as the ith value in the vector.
(vector-fill! vec val)
Standard Vector Procedure. Fill vec with multiple copies of val.
(vector-length vec)
Standard Vector Procedure. Determine the size of vec.
(vector-ref vec n)
Standard Vector Procedure. Get the nth element of vec. Note that elements are numbered starting at 0.
(vector-set! vec k val)
Standard Vector Procedure. Set the kth element of vec to val. (Note that vectors use 0-based indexing.)

W

(write value)
Standard File Procedure. Print the verbose representation of the specified value to standard output.
(write value output-port)
Standard File Procedure. Print the verbose representation of the specified value to the specified port.
(write-char ch)
Standard I/O Procedure. Write the the given character to the screen.
(write-char ch output-port)
Standard File Procedure. Write the the given character to the specified port.

Creative Commons License

Samuel A. Rebelsky, rebelsky@grinnell.edu

Copyright (c) 2007-8 Janet Davis, Matthew Kluber, and Samuel A. Rebelsky. (Selected materials copyright by John David Stone and Henry Walker and used by permission.)

This material is based upon work partially supported by the National Science Foundation under Grant No. CCLI-0633090. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.

This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/2.5/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.