CSC151.02 2010S Functional Problem Solving : Reference

Scheme Procedures A-Z


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.
(^and f1 f2 ... fn)
Traditional Higher-Order Procedure. A higher-order version of and. Creates a new procedure that, when applied to some values, returns (and (f1 values) (f2 values) ... (fn values)).
(^not pred?)
Traditional Higher-Order Procedure. A higher-order version of not. Creates a new procedure, that, when applied to some values, returns the opposite of pred?. That is, (1) if pred? returns a truish value when applied to some parameters, the new procedure returns #f when applied to those same parameters; (2) if pred? returns false when applied to some parameters, the new procedure returns #t when applied to those same parameters.
(^or f1 f2 ... fn)
Traditional Higher-Order Procedure. A higher-order version of or. Creates a new procedure that, when applied to some values, returns (or (f1 values) (f2 values) ... (fn values)).

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

(caar lst)
Standard List Procedure. If lst's first element is a list, gets the first element of that first element, the the car of the car of lst. If lst is not a list, or its first element is not a list, reports an error.
(cadr lst)
Standard List Procedure. Get the second element of lst, the car of the cdr of lst
(caddr lst)
Standard List Procedure. Get the third element of lst, the car of the cdr of the cdr of lst.
(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.
(cadr lst)
Standard List Procedure. Get the second element of lst, the car of the cdr of lst
(ceiling num)
Standard Scheme Procedure. Find the smallest integer greater than or equal to num. That is, round down.
(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.)
(color->rgb string)
MediaScheme Color Procedure. Convert any of the myriad representations of colors to a corresponding RGB color.
(color-name? val)
MediaScheme Color Procedure. Checks to see if val is a string representing a color in the database of colors.
(color-name->rgb string)
MediaScheme Color Procedure. Build an RGB color that corresponds to the given color name.
(complex? val)
Optional Scheme Procedure. Determine whether val can be interpreted as a complex number.
(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.
(constant value)
Traditional Higher-Order Procedure. Create a new function that always returns value, no matter what parameters it is applied to.
(context-get-bgcolor)
MediaScheme GIMP Procedure. Returns GIMP's current background color (as an RGB color).
(context-get-brush)
MediaScheme GIMP Procedure. Get GIMP's active brush.
(context-get-color-names)
MediaScheme GIMP Procedure. Get a vector of all the available color names.
(context-get-fgcolor)
MediaScheme GIMP Procedure. Returns GIMP's current foreground color (as an RGB color).
(context-list-brushes)
MediaScheme GIMP Procedure. List all valid brush names.
(context-list-brushes pattern)
MediaScheme GIMP Procedure. List all the valid brush names that contain pattern.
(context-list-colors)
MediaScheme GIMP Procedure. List all valid color names.
(context-list-colors pattern)
MediaScheme GIMP Procedure. List all the valid color names that contain pattern.
(context-list-fonts)
MediaScheme GIMP Procedure. List all valid font names.
(context-list-fonts pattern)
MediaScheme GIMP Procedure. List all the available font names that contain pattern.
(context-set-bgcolor! color)
MediaScheme GIMP Procedure. Sets GIMP's current background color to color.
(context-set-brush! brush-name)
MediaScheme GIMP Procedure. Sets GIMP's current brush to brush-name.
(context-set-fgcolor! color)
MediaScheme GIMP Procedure. Sets GIMP's current foreground color to color.
(context-update-displays!)
MediaScheme GIMP Procedure. Update all of the displays to show changes to images.

D

(delete-file filename)
Common File Procedure. Delete the file specified by filename. If the file doesn't exist, reports an error.
(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? value)
MediaScheme Drawing Procedure. Determine if value can be interpreted as a drawing.
drawing-blank
MediaScheme Drawing Constant. An empty drawing. Included for the sake of completeness. Also provides a useful base case for recursion over grouped drawings.
(drawing-blank? value)
MediaScheme Drawing Procedure. Determine if value can be interpreted as a blank drawing.
(drawing-bottom drawing)
MediaScheme Drawing Procedure. Determine the row of the bottom edge of a drawing.
(drawing-color drawing)
MediaScheme Drawing Procedure. Determine the color of a simple drawing. (Does not work for compound drawings.)
(drawing-compose list-of-drawings)
MediaScheme Drawing Procedure. Create a new drawing by overlaying all of individual drawings in list-of-drawings. Note that the drawings are stacked first to last, so the first drawing in the list is at the bottom and the last in the list is at the top.
(drawing-group drawing1 drawing2 ... drawingn)
MediaScheme 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)
MediaScheme Drawing Procedure. Determine the approximate height of a drawing.
(drawing-hscale drawing factor)
MediaScheme 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)
MediaScheme 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)
MediaScheme Drawing Procedure. Create a new drawing by overlaying drawing2 on top of drawing1.
(drawing-left drawing)
MediaScheme Drawing Procedure. Determine the column of the left edge of a drawing.
(drawing-outline drawing brush)
MediaScheme 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)
MediaScheme 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)
MediaScheme Drawing Procedure. Determine the column of the right edge of a drawing.
(drawing-scale drawing factor)
MediaScheme 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 height)
MediaScheme 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)
MediaScheme Drawing Procedure. Determine the row of the top edge of a drawing.
(drawing-type drawing)
MediaScheme 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
MediaScheme Drawing Constant. A unit circle. That is, a circle with diameter 1, filled in black, centered at (0,0).
drawing-unit-square
MediaScheme Drawing Constant. A unit square. That is, a square with edge-length 1, filled in black, centered at (0,0).
(drawing-vscale drawing factor)
MediaScheme 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)
MediaScheme 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)
MediaScheme 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.
(error message)
Standard Procedure. Print the message (which is typically a string) and then stop the computation currently underway.
(error 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.
(even? int)
Standard Scheme Procedure. Determine whether the integer value int is even (that is, has a remainder of 0 when divided by 2).
(exact? num)
Standard Scheme Procedure. Determine whether the numeric value num is represented exactly (that is, not approximated).
(exact->inexact num)
Standard Scheme Procedure. Create an inexact representation of num.
(expt base power)
Standard Scheme Procedure. Compute basepower.

F

(file-exists? filename)
Standard File Procedure. Determine whether a file with the given name exists.
(filter pred? lst)
Traditional List Procedure. Select the elements of lst for which pred? holds. (filter means to “filter in”, not to “filter out”.)
(floor num)
Standard Scheme Procedure. Find the largest integer less than or equal to num. That is, round down.
(for-each proc! lst)
Standard Higher-Order List Procedure. Apply proc! to 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)
MediaScheme GIMP Procedure. Determine if val is an image.
(image-blot! image col row)
MediaScheme GIMP Procedure. Draw a spot in image at (col,row) with the current brush and foreground color.
(image-calculate-pixels! image fun
MediaScheme GIMP Procedure. Fills in all the pixels in the image by setting the color at each position to the result of applying fun to the column and row. fun should have the form (lambda (col row) color). Unlike image-compute-pixels!, which can compute pixels in any order, image-calculate-pixels! is guaranteed to do a row-by-row, left-to-right scan through the image. However, image-calculate-pixels! is likely to be slower than image-compute-pixels! (although faster than coding the iteration yourself).
(image-compute pos2color width height)
MediaScript GIMP Procedure. Create a new width-by-height image by using pos2color (a function of the form (lambda (col row) color)) to compute the color at each position in the image. compute
(image-compute-pixels! image pos2color)
MediaScheme GIMP Procedure. Set each pixel in the image to the result of applying function to the position of the pixel. function must have the form (lambda (col row) expression-to-compute-color).
(image-draw-line! image col1 row1 col2 row2)
MediaScheme GIMP Procedure. Draw a line in image from (col1,row1) to (col2,row2). Uses the current brush and foreground color.
(image-fill-selection! image)
MediaScheme GIMP Procedure. Fill the selected region of the given image with the current foreground color.
(image-get-pixel image column row)
MediaScheme GIMP Procedure. Get the pixel at the specified position in the image.
(image-height image)
MediaScheme GIMP Procedure. Determine the height of the given image
(image-load filename)
MediaScheme GIMP 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)
MediaScheme GIMP Procedure. Create a new image of specified width and height.
(image-save image fname)
MediaScheme GIMP Procedure. Save image in the specified file (which should provide the full path to the file). The type of the image (JPEG, GIF, PNG, etc.) is determined by the suffix of the file name.
(image-scan image proc!)
MediaScheme GIMP Procedure. Scans through the image, applying proc! the the column, row, and color at each position. proc! should have the form (lambda (col row color) ...). In contrast to many of the other image iteration procedures, image-scan is guaranteed to scan row-by-row from top-to-bottom, scanning each row from left to right.
(image-select-all! image)
MediaScheme GIMP Procedure. Selects all of the pixels in the image.
(image-select-ellipse! image selection-type left top width height)
MediaScheme GIMP Procedure. Select an ellipse whose left margin is left, top margin is top, width is width and height is height. If selection-type is REPLACE, the ellipse replaces the current selection. If selection-type is ADD, the ellipse is added to the current selection. If selection-type is SUBTRACT, the ellipse is subtracted from the current selection. If selection-type is INTERSECT, the ellipse is intersected with the current selection (that is, only points that are in both the current selection and the ellipse remain selected).
(image-select-inverse! image)
MediaScheme GIMP Procedure. Selects the inverse of all selected images in the image.
(image-select-nothing! image)
MediaScheme GIMP Procedure. Clears the current selection. Afterwards, nothing is selected.
(image-select-polygon! image selection-type positions)
MediaScheme GIMP Procedure. Select a polygon described by the given list of positions (each created by position-new). If selection-type is REPLACE, the polygon replaces the current selection. If selection-type is ADD, the polygon is added to the current selection. If selection-type is SUBTRACT, the polygon is subtracted from the current selection. If selection-type is INTERSECT, the polygon is intersected with the current selection (that is, only points that are in both the current selection and the polygon remain selected).
(image-select-rectangle! image selection-type left top width height)
MediaScheme GIMP Procedure. Select an rectangle whose left margin is left, top margin is top, width is width and height is height. If selection-type is REPLACE, the rectangle replaces the current selection. If selection-type is ADD, the rectangle is added to the current selection. If selection-type is SUBTRACT, the rectangle is subtracted from the current selection. If selection-type is INTERSECT, the rectangle is intersected with the current selection (that is, only points that are in both the current selection and the rectangle remain selected).
(image-set-pixel! image column row rgb-color)
MediaScheme GIMP Procedure. Set the pixel at the specified position to the new color.
(image-show image)
MediaScheme GIMP Procedure. Opens a new window with the image.
(image-stroke-selection! image)
MediaScheme GIMP Procedure. Traces the edge of the selected region of the given image with the current brush and foreground color.
(image-transform! image fun)
MediaScheme GIMP 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)
MediaScheme GIMP 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)
MediaScheme GIMP 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)
MediaScheme GIMP Procedure. Determine the width of the given image.
(inexact? num)
Standard Scheme Procedure. Determine whether the numeric value num is represented inexactly (that is, approximated).
(inexact->exact num)
Standard Scheme Procedure. Create an exact representation of num. (Of course, if num was already approximated, the result, while exact, still approximates whatever num approximated.)
(input-port? val)
Standard File Predicate. Determine if val is an open input port.
(integer? val)
Standard Scheme Procedure. Determine whether val is an integer.
(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.
(left-section binproc left)
Traditional Higher-Order Procedure. Given a two-parameter procedure and a value, creates a new anonymous one-parameter procedure by filling in the first (left) parameter of the procedure. The new procedure, when applied to a value, v, returns (binproc left v).
(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->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-drop lst n)
List Procedure. Build a new list that consists of all but the first n elements of lst.
(list-ref lst n)
Standard List Procedure. Get the nth element of lst. Note that elements are numbered starting at 0.
(list-take lst n)
List Procedure. Build a new list that consists of the first n elements of lst.
(l-s binproc left)
Traditional Higher-Order Procedure. A shorthand for left-section.

M

(make-list n val)
Customary List Procedure. Make a new list that consists of n copies of val.
(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.
(max v1 v2)
Standard Scheme Procedure. Find the larger of v1 and v2.
(max v1 v2 ... vn)
Standard Scheme Procedure. Find the largest of v1 through vn.
(min v1 v2)
Standard Scheme Procedure. Find the smaller of v1 and v2.
(min v1 v2 ... vn)
Standard Scheme Procedure. Find the smallest of v1 through vn.
(modulo value modulus)
Standard Scheme Procedure. In a number line segmented into modulus-sized sections, gives the offset of value from the start of its section.

N

(negative? num)
Standard Scheme Procedure. Determine whether the numeric value num is negative (less than zero).
(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? val)
Standard Scheme Procedure. Determine if val is a number.
(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))))).
(odd? int)
Standard Scheme Procedure. Determine whether the integer value int is odd (that is, has a remainder of 1 when divided by 2).
(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? value)
MediaScheme Position Procedure. Determine if value is a position (or can be interpreted as such).
(position-col pos)
MediaScheme Position Procedure. Extract the column from position pos.
(position-distance pos1 pos2)
MediaScheme Position Procedure. Compute the distance between pos1 and pos2.
(position-interpolate pos1 pos2 percent)
MediaScheme Position Procedure. Create a new position which is percent (expressed as a real number between 0 and 1) of the way from pos1 to pos2
(position-new col row)
MediaScheme Position Procedure. Build a new position that represents the point at (col,row).
(position-offset position hoff voff)
MediaScheme Position Procedure. Create a new position, offset from position horizontally by hoff and vertically by voff.
(position-row pos)
MediaScheme Position Procedure. Extract the row from position pos.
(positive? num)
Standard Scheme Procedure. Determine whether the numeric value num is positive (greater than zero).

Q

(quotient dividend divisor)
Standard Scheme Procedure. Find the quotient of dividend and divisor, both of which must be integers. The quotient is the whole part of the result of dividing dividend by divisor.

R

(random-positions n cols rows)
MediaScheme Position Procedure. Create n positions, each of which is difficult to predict and each with a non-negative column less than cols and a non-negative row less than rows.
(rational? val)
Optional Scheme Procedure. Determine whether val can be interpreted as a rational number.
(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.
(real? val)
Standard Scheme Procedure. Determine whether val is a real number.
(region-calculate-pixels! image left top width height fun
MediaScheme GIMP Procedure. Creates a region of the image by applying fun at each position in the region. fun should have the form (lambda (col row) color). Unlike region-compute-pixels!, which can compute pixels in any order, region-calculate-pixels! is guaranteed to do a row-by-row, left-to-right scan through the image. However, region-calculate-pixels! is likely to be slower than region-compute-pixels! (although faster than coding the iteration yourself).
(region-compute-pixels! image left top width height pos2color)
MediaScheme GIMP 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 of the form (lambda (col row) expression-to-compute-color).
(region-scan image left top width height proc!)
MediaScheme GIMP Procedure. Scans through a region of the image, applying proc! at each position in the region. proc! should have the form (lambda (col row color) ...). In contrast to many of the other region procedures, region-scan is guaranteed to scan row-by-row from top-to-bottom, scanning each row from left to right.
(remainder dividend divisor)
Standard Scheme Procedure. Compute the remainder after doing whole-number division of dividend by divisor.
(repeat i proc!)
Extended Scheme Procedure. Call proc! (a zero-parameter procedure, a.k.a., a “thunk”) i times.
(repeat i proc! val)
Extended Scheme Procedure. Evaluate (proc! val)i times.
(repeat i proc! v1 ... vn)
Extended Scheme Procedure. Evaluate (proc! v1 ... vn)i times.
(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)
MediaScheme Color Predicate. Determine if value can be interpreted as an RGB color.
(rgb->color-name rgb-color)
MediaScheme Color Procedure. Convert the given color to a string that names a similar color. Note that this conversion approximates the RGB color as there are many fewer names than colors.
(rgb->rgb-list rgb-color)
MediaScheme Color Procedure. Convert the given color to a list of its three components.
(rgb->string rgb-color)
MediaScheme Color 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)
MediaScheme Color Procedure. Build a bluer version of the given color.
(rgb-blue color)
MediaScheme Color Procedure. Get the blue component of an RGB color.
(rgb-complement rgb-color)
MediaScheme Color Procedure. Compute the psuedo-complement of the given color.
(rgb-darker rgb-color)
MediaScheme Color Procedure. Build a darker version of the given color.
(rgb-greener rgb-color)
MediaScheme Color Procedure. Build a greener version of the given color.
(rgb-green color)
MediaScheme Color Procedure. Get the green component of an RGB color.
(rgb-lighter rgb-color)
MediaScheme Color Procedure. Build a lighter version of the given color.
(rgb-list->rgb rgb-lst)
MediaScheme Color Procedure. Converts a list representation of a color of the form (r g b) into an RGB color.
(rgb-new r g b)
MediaScheme Color 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)
MediaScheme Color 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)
MediaScheme Color Procedure Build a redder version of the given color.
(rgb-red color)
MediaScheme Color Procedure. Get the red component of an RGB color.
(rgb-rotate rgb-color)
MediaScheme Color 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.
rgb-transparent
MediaScheme Color Constant. A special color value, used by image-compute-pixels! (and variants thereof). If the color function returns rgb-transparent for a particular position, the color at that position is left unchanged.
(right-section binproc right)
Traditional Higher-Order Procedure. Given a two-parameter procedure and a value, creates a new anonymous one-parameter procedure by filling in the second (right) parameter of the procedure. The new procedure, when applied to a value, v, returns (binproc v right).
(round num)
Standard Scheme Procedure. Round num toward the nearest integer. If the decimal portion of num is greater than 1/2, rounds up. If the decimal portion is less than 1/2, rounds down. If the decimal portion equals 1/2, may round in either direction. (In most implementations, numbers with fractional portions equal to 1/2 round toward the even number.)
(r-s binproc right)
Traditional Higher-Order Procedure. A shorthand for right-section.

S

(selection-compute-pixels! image pos2color)
MediaScheme GIMP Procedure. Set each pixel in the selected area of the image to the result of applying function to the position of the pixel. function must have the form (lambda (col row) expression-to-compute-color).
(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

(truncate num)
Standard Scheme Procedure. Remove any fractional part from num. That is, round toward zero.
(turtle-clone turtle)
MediaScheme Turtle Constructor. Make a clone of turtle (same position, direction, color, brush, etc.).
(turtle-down! turtle)
MediaScheme Turtle Procedure. Put turtle's brush down. When the turtle moves forward, it draws with the brush.
(turtle-face! turtle angle)
MediaScheme Turtle Procedure. Make turtle face the diretion specified by angle (clockwise from right).
(turtle-forward! turtle distance)
MediaScheme Turtle Procedure. Moves turtle forward by the specified distance.
(turtle-new image)
MediaScheme Turtle Constructor. Build a new turtle that draws on image.
(turtle-set-brush! turtle brush)
MediaScheme Turtle Procedure. Set the brush that turtle draws with.
(turtle-set-color! turtle color)
MediaScheme Turtle Procedure. Set the color in which turtle draws.
(turtle-teleport! turtle col row)
MediaScheme Turtle Procedure. Move turtle to (col,row). Do not draw along the way.
(turtle-turn! turtle angle)
MediaScheme Turtle Procedure. Rotate turtle clockwise by angle degrees.
(turtle-up! turtle)
MediaScheme Turtle Procedure. Lifts turtle's brush. When turtle moves forward, it will not draw.
(turtle-world turtle)
MediaScheme Turtle Procedure. Determine the world on which turtle resides.

U

(usleep usec)
Optional Scheme Procedure. Pause for usec microseconds.

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

(when test exp1 exp2 ... expn)
Optional Scheme Keyword. Evaluate test. If it holds, evaluate each expression in turn. Otherwise, do nothing.
(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.

Z

(zero? num)
Standard Scheme Procedure. Determine whether the numeric value num is zero.

Creative Commons License

Samuel A. Rebelsky, rebelsky@grinnell.edu

Copyright (c) 2007-10 Janet Davis, Matthew Kluber, Samuel A. Rebelsky, and Jerod Weinman. (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.