dome-version Returns a string that represents the version of DOME being used. blue Returns a number between 0 and 1 representing the blue component of the given color value (see also red, green). brightness Returns a number between 0 and 1 representing the brightness level of the given color value (see also hue, saturation). Color values are usually obtained via a GraphicsContext instance used when printing graphs through user-supplied print drivers. cyan Returns a number between 0 and 1 representing the cyan component of the given color value (see also magenta, yellow). Color values are usually obtained via a GraphicsContext instance used when printing graphs through user-supplied print drivers. green Returns a number between 0 and 1 representing the green component of the given color value (see also red, blue). Color values are usually obtained via a GraphicsContext instance used when printing graphs through user-supplied print drivers. hue Returns a number between 0 and 1 representing the hue component of the given color value (see also brightness, saturation). Color values are usually obtained via a GraphicsContext instance used when printing graphs through user-supplied print drivers. magenta Returns a number between 0 and 1 representing the magenta component of the given color value (see also cyan, yellow). Color values are usually obtained via a GraphicsContext instance used when printing graphs through user-supplied print drivers. red Returns a number between 0 and 1 representing the red component of the given color value (see also blue, green). Color values are usually obtained via a GraphicsContext instance used when printing graphs through user-supplied print drivers. saturation Returns a number between 0 and 1 representing the saturation component of the given color value (see also hue, brightness). Color values are usually obtained via a GraphicsContext instance used when printing graphs through user-supplied print drivers. yellow Returns a number between 0 and 1 representing the yellow component of the given color value (see also cyan, magenta). Color values are usually obtained via a GraphicsContext instance used when printing graphs through user-supplied print drivers. make-color Creates a color value object whose red value is the first argument, green value is the second argument and blue value is the third argument. make-rgb-color Creates a color value object whose red value is the first argument, green value is the second argument and blue value is the third argument. make-cmy-color Creates a color value object whose cyan value is the first argument, magenta value is the second argument and yellow value is the third argument. make-hsb-color Creates a color value object whose hue value is the first argument, saturation value is the second argument and brightness value is the third argument. color Returns a color-value representing the color of the font or graph object. set-color! Sets the color of the receiver to the color-value argument. default-font-description Returns the system's default font-description. family Returns a string or a vector representing the font's family. If a vector is returned, it is a vector of strings representing alternative names for the font family. set-family! Sets the receiver's family to the string argument. fixed-width Returns a boolean that indicates whether all characters in the font can be expected to be the same width. set-fixed-width! Sets the value of the font's fixed-width property to the boolean argument. The font's set-width property indicates whether all characters in the font can be expected to be the same width. italic Returns a boolean indicating whether the font is italic or not. set-italic! Sets the value of the font's italic property to the boolean argument. bold Returns a boolean indicating whether the font is bold or not. set-bold! Sets the value of the font's bold property to the boolean argument. serif Returns a boolean indicating whether the font is serif or not. set-serif! Sets the value of the font's serif property to the boolean argument. size Returns the size of the font in pixels. set-size! Sets the size of the font in pixels. strikeout Returns a boolean indicating whether the font is represented with a strikeout. set-strikeout! Sets the value of the font's strikeout property to the boolean argument. underline Returns a boolean indicating whether the font is represented with an underline. set-underline! Sets the value of the font's underline property to the boolean argument. in-new-environment-do Creates a new, parent-less environment in which to evaluate the supplied body expressions. show-progress-begin Show-progress-begin is just like begin, except that a progress meter is displayed during its execution. The meter displays the message supplied as a string as the first argument and a partially-filled circle. The circle shows the percentage of expressions that have been evaluated. Note that this, at best, only approximates the actual proportions involved, since show-progress-begin has no clues about how long it will take to evaluate each expression.. show-progress-for-each Show-progress-for-each is just like for-each, except that a progress meter is displayed during its execution. The meter displays the message supplied as a string as the first argument and a partially-filled circle. The circle shows the percentage of top-level list elements that have been processed by the given procedure. Note that this, at best, only approximates the actual proportions involved, since show-progress-for-each has no clues about how long it will take to process each set of elements. string->filename Converts the argument string into a filename object. This procedure does not require the corresponding file to exist, but an error may result if the syntax of the name is not appropriate for the host operating system. Alternatively, certain "adjustments" may be made when converting the string to a filename that make it more palatable to the host. See also construct, filename->string. filename->string Converts the argument filename into an Alter string. See also string->filename. type->symbol Converts a type (e.g., grapething, color-type, procedure-type) into a symbol. This is useful for dealing with GrapE objects. landscape Given a graphics context instance, the landscape operation returns a boolean value indicating whether or not the user selected landscape orientation in the print dialog. This operation is useful primarily in user-defined DOME printer drivers. (See appendix.) filename Given a graph model instance, the filename operation returns an instance of filename-type that represents the file the model was last saved in. open-models This procedure returns a list of graphmodel instances that are currently open (but not necessarily displayed) within DOME. nodes The nodes operation retrieves the list of nodes contained in the given graphmodel instance. Only the nodes at the top level within the given graphmodel are returned; the list does NOT contain any nodes from subdiagrams. See also arcs. get-property Gets the value of the named property from the given object. The object is usually an instance of grapething or one of its subclasses, but get-property will also work on instances of other GrapE classes. It is an error if the property name is not valid for the given class of object. The DOME Tool Specifications define the properties on the various DOME objects. The property name which IS case sensitive can either by a string or a symbol. set-property! Sets the value of the propnamestring property on the grapething object to the specified value. Set-property may work on non-GrapEThing objects, but its behavior is unspecified in those cases. It is an error if the property name is not valid for the given class of object. The DOME Tool Specifications define the properties on the various DOME objects. The property name which IS case sensitive can either by a string or a symbol. has-property-set? Returns #t if the given grapething object has a value set for the named property. It is an error if the property name is not valid for the given class of object. The DOME Tool Specifications define the properties on the various DOME objects. The property name which IS case sensitive can either by a string or a symbol. unset-property! Removes any value bound to the specified property for the given object. If the optional third argument is supplied, the value is unbound only if the current binding is eq? to the third argument. It is an error if the property name is not valid for the given class of object. The DOME Tool Specifications define the properties on the various DOME objects. The property name which IS case sensitive can either by a string or a symbol. property-definitions Returns a dictionary representing the (non-default) property settings for the given object. add-interest Create a dependency on the first argument so that an action is triggered when it changes. Specifically, the given lambda expression is executed every time the specified "aspect" of the object changes. The lambda expression is passed the changed object, the aspect that changed (e.g., name) and the previous value (e.g., "foo") as parameters. Two additional parameters are given to add-interest to make it easier to remove the dependencies. The first of these, the fourth argument to add-interest, is the dependent. In typical usage, the lambda expression will execute some behavior on the dependent, such as updating a property or re-propagating the change in another direction. If the dependent goes away for some reason, DOME will automatically remove the dependencies registered against it. If a dependent needs to be able to selectively remove dependencies, the optional sixth argument may be used to create such dependencies. This same symbol can be given to remove-interest. The second (aspect) and optional fifth (role) arguments may be either strings or symbols. Example: Display a message to the user when the description changes: (add-interest self 'description (lambda (changed-object changed-aspect old-value) (message-to-user (append old-value " -> " (description changed-object)))) self) See also remove-interest. remove-interest Remove a previously created dependency on the first argument. The second argument indicates the aspect or property of interest; all dependencies observing that aspect and whose dependent matches the third argument are removed. If the optional fourth argument is supplied, the dependencies must also have been created with that role. If none of the dependencies match the pattern derived from the arguments, no dependencies are removed. Example: Remove the interest expressed earlier (see add-interest) (remove-interest self 'description self) See also add-interest. bottom-margin Returns the size of the bottom margin in inches for a page generated by the document-context. set-bottom-margin! Sets the size of the bottom margin for a page generated by the document-context. The size is in inches. top-margin Returns the size of the top margin in inches for a page generated by the document-context. set-top-margin! Sets the size of the top margin for a page generated by the document-context. The size is in inches. cr Adds a carriage return (newline) to the document-context's stream. If the optional positive integer argument is passed then a number of carriage returns equal to the value of the integer are added to the document-context's stream. dec-indent-level! Decrements the document-context's indent level counter. inc-indent-level! Increments the document-context's indent level counter. indent Adds a number of spaces equal to the value of the receiver's indent-level multiplied by its indent-size to the receiver's stream. indent-level Returns the value of the receiver's indent-level. The indent-level is multiplied by the receiver's indent-size to determine the total number of spaces to use when indenting. set-indent-level! Sets the value of the receiver's indent-level. The indent-level is multiplied by the receiver's indent-size to determine the total number of spaces to use when indenting. indent-size Returns the value of the receiver's indent-size. The indent-size is multiplied by the receiver's indent-level to determine the total number of spaces to use when indenting. set-indent-size! Sets the value of the receiver's indent-size. The indent-size is multiplied by the receiver's indent-level to determine the total number of spaces to use when indenting. left-margin Returns the size of the left margin in inches for a page generated by the receiver. set-left-margin! Sets the size of the left margin for a page generated by the receiver. The size is in inches. right-margin Returns the size of the right margin in inches for a page generated by the receiver. set-right-margin! Sets the size of the right margin for a page generated by the receiver. The size is in inches. next-put Adds the string argument to the receiver's output stream. page-height Returns the size of the height of a page generated by the receiver in inches. set-page-height! Sets the width a page generated by the receiver. The size is in inches. page-width Returns the size of the width of a page generated by the receiver in inches. set-page-width! Sets the size of the width of a page generated by the receiver. The size is in inches. port Returns the receiver's current output port. set-port! Sets the receiver's current output port to the argument. baseline Answer the distance from the top of the line to the bottom of most of the characters (by convention, bottom of A) in the current style used by the model to render text. set-face! Sets the name of the font family that the reliever should use when drawing strings with the draw-string operation. relative-scale Returns a value like 1.0 or 1.5 (150%), etc that can scale fonts or other values. set-relative-scale! Sets a value like 1.0 or 1.5 (150%), etc that can scale fonts or other values. translation Returns the point used by the receiver to translate points when drawing graphic objects. set-translation! Sets the point used by the receiver to translate points when drawing graphic objects. scale Returns a point representing the scale factor for all points used when drawing graphics. set-scale! Sets the point used by the receiver to scale points when drawing graphic objects. start-para Starts a new paragraph. If the optional style parameter is passed, a new paragraph with that style is created, otherwise the receiver's current style is used. write-preamble Writes a preamble on the receiver's stream. write-postamble Writes a postamble on the receiver's stream. write-bitmap Writes a bitmap of the graph into the specified filename using the indicated format. Supported formats are currently 'gif, 'mif (Maker Interchange Format; 'frame and 'framemaker are aliases), 'xwd and 'eps (Encapsulated PostScript; 'epsf is an alias). open Sets the receiver's port to an output-port. If the optional output argument is not provided then a window is open and the port is set to the window. If the optional output argument is passed it must be a string, filename or output-port. If it is a string, the string is converted to a filename, the file is opened and the port is set to the resulting output-port. If it is a filename, the file is opened and the port is set to the resulting output-port. If it is an output-port, the port is set to it. An error results if any other type of argument is passed. line-width Given a graphics context instance, the line-width operation returns an integer value indicating how many pixels wide the pen is for drawing lines. This operation is useful primarily in user-defined DOME printer drivers. (See appendix.) set-line-width! Sets the line width of the context to the integer argument. The value indicates how many pixels wide the pen is for drawing lines. print-size Returns the maximum dimension in inches of printed data when drawing graphics. set-print-size! Sets the maximum dimension in inches of printed data when drawing graphics. scale-to! Sets the scale and translation using the rectangle argument. The scale is set to a point whose x and y coordinates are equal to the larger of the print size divided by the rectangle's width or the print size divided by the rectangle's height. The translation is set to the rectangle's upper left corner point negated. line-style This operation returns a symbol representing the current dash pattern to be used when drawing lines. The symbol returned is one of {normal simpledash longdash dot dashdot dashdotdot phantom chain shortdash hidden}. set-line-style! This operation sets the context's line style to the symbol argument. The symbol represents the current dash pattern to be used when drawing lines. The symbol is one of {normal simpledash longdash dot dashdot dashdotdot phantom chain shortdash hidden}. direction Returns a symbol representing the semantic direction of the given boundary node in a graph. The possible values are 'in, 'out and 'inout. paint-color Given a graphics context instance, the paint-color operation returns a colorvalue instance representing the current pen color for drawing objects. This operation is useful primarily in user-defined DOME printer drivers. (See appendix.) See red, green, blue, hue, saturation, brightness, cyan, magenta and yellow operations for extracting color components from a colorvalue instance. set-paint-color! Given a graphics context instance, sets the context's current paint color to the color value argument. The argument is a colorvalue instance representing the current pen color for drawing objects. See make-rgb-color, make-hsb-color, and make-cmy-color for making a colorvalue instance. face Given a graphics context instance, the face operation returns a string representing the current typeface for displaying text objects. This operation is useful primarily in user-defined DOME printer drivers. (See appendix.) The possible return values are: "Helvetica", "Times", "Courier" and "Palatino". background-color Given a graphics context instance, the background-color operation returns a color value object that represent the current background color used by the context. draw-line Draws a line on the given graphics context between the two supplied points (see "point?"). This primitive is used mainly in user-defined DOME Tool Specification/ProtoDOME methods. draw-polyline Draws a polyline on the given graphics context between the supplied points (see "point?"). This primitive is used mainly in user-defined DOME Tool Specification/ProtoDOME methods. draw-arc Draws an arc on the given graphics context. If the fill-flag is true, the arc will be filled in a pie-wedge fashion. The arc is drawn to inscribe the specified rectangle. The start and sweep angles are in degrees. Zero degrees is rightward along the x axis, and the sweep angle proceeds clockwise. draw-rectangle Draws a rectangle on the given graphics context. If the fill-flag is true, the rectangle will be filled; otherwise only the border will be drawn. draw-string Renders the string at the specified position on the graphics context. The position specifies the location of the left side and baseline of the first character. draw-grapething Renders the grapething at the specified position on the graphics context. finalize This is the call that is made to the document-context after the document has been generated. It is used to close files, etc. edit Given a GraphModel instance, the edit operation forces the given graphmodel instance to be assigned an editor window (if it doesn't already have one), and then forces that window to be popped to the front. If the graph does not already have a window, the behavior of the edit operation follows what is described in the DOME User's Manual for the preferences setting 'Use Same Editor'. Given a string, the edit operation treats the string as the name of a file and attempts to open an editor on the file's contents. If the file contains a DOME model, the operation is the same as (edit (load string)). If the file contains Alter text (and the first character in the file is a semicolon), DOME will open an Alter evaluator window on the file's contents. If neither of the above is true, DOME gives the user the option of opening the file into a text editing window. views Returns a list of views (at the next level only) of the given grapething instance. The elements of the returned list will be of the same type as the argument supplied to the views operation. If there are no views, an empty list will be returned. See also master. The following express will always be true: (memq self (views (master self))) where self is some graphobject instance and (not (nil? (master self))) parent Returns the parent of the given graph, if any. If the argument has no parent, nil is returned. name Returns a string representing the name of the given grapething instance. The name operation is defined on classes NamedNode, GraphObjectAttribute, NamedDirArc, GraphModel, and their subclasses. See also set-name!. When given a package it returns the name of the package. origin Given an arc, the origin operation returns the node object that is at the origin end of the arc. See also destination. arcs Given a GraphModel instance, the arcs operation returns a list of the arcs present in the graph. The list includes only the arcs at the top level within the given graph; it does NOT contain any arcs from subdiagrams. See also nodes. is-kind-of This operation is obsolete. Please use is-kind-of? instead. is-kind-of? Given an object and a class, is-kind-of? returns #t if the object is an instance of the class, and returns #f if it is not. Both the object must be an instance of some non-basic class (a basic class is one of the Scheme predefined types, e.g., integer, symbol, string). Is-kind-of? is not defined on instances of basic classes. name-set! Obsolete. Use set-name! instead. set-position! Sets the absolution position of the node to be the point, if possible. Units are in pixels, and the point is a pair of the form (x . y). This operation can also be applied to arc name tags and other accessories. It is an error to apply this operation to instances of GraphObjectAttribute, since their positions are determined completely automatically, and are strictly relative to their containers. See also relative-position-set! and synchronize-display. set-relative-position! Sets the relative position of the node to be the point, if possible. Units are in pixels and the point is a pair of the form (x . y). The position given is relative to the node's container (possibly the graph, whose position is considered to be (0 . 0). Some subclasses of DoMENode may generate an error if set-relative-position! is applied to them. In particular, subclasses of GraphObjectAttribute typically resist attempts to manually adjust their relative positions. See also set-position! and synchronize-display. properties Returns a dictionary of the object's properties. rationale Returns the value of the rationale property of the given grapething instance. The returned value is a string (possibly empty). outgoing-arcs Given a node instance, the outgoing-arcs operation returns a list of the arcs emanating from the node. See also incoming-arcs. components Given a GrapeThing instance, the components operation returns a list of the components contained within the instance. For GraphModels, the list will contain nodes and arcs. For nodes, the list will contain nodes. For arcs, the list may contain nodes and a GrapEArcName. display-errors The display-errors procedure displays the given list of errors in a scrollable window so that the object with a problem can be directly inspected or focussed on. The list is an association list where the car of each association is a GrapEVisualThing or a list of GrapEVisualThings, and the cdr is an error message (a string). (define g (new-top-model DFDGraph)) (display-errors (list (list g "Name Required"))) new-top-model Creates a new instance of the given graphmodel class and initializes it as a new top-level model (i.e., it has no parent). New-top-model does NOT open an editor window on the resulting instance. The edit operation will do this. See also new-child-model, nodes, arcs, new-in. new-child-model Creates a new instance of the given graphmodel class as a child of the specified graphobject (node or arc). New-child-model does NOT open an editor window on the resulting instance. The 'edit' operation will do this. See also new-top-model, new-in, nodes and arcs. description If the first argument is an instance of GrapEThing, description returns the value (a string) of the description property of the object. If the first argument is a procedure or operation, and the optional second argument is missing, description returns a string describing it. Normally the description text is retrieved from the file (construct (construct (dome-home) 'lib') 'alterdsc.txt'), but if the optional argument is supplied, it becomes the description for the procedure or operation. methods Returns an alist (see assoc) containing the types and procedures currently defining the operation. Each alist component is of the form (class . procedure). destination Given an arc, the destination operation returns the node object that is at the destination end of the arc. See also origin. Given a GraphObjectReference, destination returns the node for which the argument is a surrogate. resolve-identity Attempts to resolve the reference to the remote DOME object. If successful, the operation answers the remote object. If unsuccessful, DOME raises an error dialog and the operation returns nil. During the attempt to resolve the identity, DOME may cause the file containing the object to be loaded into memory. instances The argument to the instances operation must be an archetype, that is, a node that resides on the shelf (see the DOME User's Manual). The instances operation will return a list of all of the archetype's instances. See also archetype. archetype Given an instance of a node, the archetype operation returns either nil (if the node has no archetype), or the node instance that serves as the argument's archetype. An archetype is a node that resides on the shelf (see the DOME User's Manual). By definition, the archetype of an archetype is itself. paint Given a graphics context instance, the paint operation returns a two-element vector; the first value is a colorvalue instance representing the current pen color for drawing objects and the second value is a symbol representing the pen stroke style ('solid or 'gray). This operation is useful primarily in user-defined DOME printer drivers. (See appendix.) See also paintcolor, paintstyle. The result of the paint operation is the same as the following (where gc is the graphicscontext instance): (let ((p (make-vector 2))) (vector-set! p 1 (paintcolor gc)) (vector-set! p 2 (paintstyle gc)) p) what-are-you Given a grapething instance, the what-are-you operation returns a string describing the instance (e.g., a user-sensible rendering of its class name). This is mainly useful for interacting with the user. new-in New-in is an operation defined on node classes and arc classes, and is used for creating new instances of nodes and arcs. Both methods require the second argument to be a graphmodel instance that is to contain the new object. The node class method accepts a third (optional) argument that specifies the pixel coordinates for the new node; if it is omitted, GrapE will use a default position that depends on the type of node. The position coordinate must be supplied as a pair whose car is the x coordinate and whose cdr is the y coordinate (y=0 is the top of the window). Units are pixels. The third and fourth arguments to the arc class method must be node instances. The third argument specifies the node that will serve as the new arc's origin; the fourth argument specifies the node that will serve as the new arc's destination. It is legal for the origin and destination to be the same object. The fifth (optional) argument must be a list of points (pairs) that serve as the intermediate route (bend) points for the arc, proceeding from the origin side to the destination side. If no route it supplied, the arc will be a straight line automatically clipped to the boundaries of the origin and destination node. The form of each point is a pair whose car is the x coordinate and whose cdr is the y coordinate. Units are pixels, and y=0 is the top of the editing area. (define g (new-top-model DFDGraph)) (define n1 (new-in DFDProcess g '(100 . 100))) => a process node (define n2 (new-in DFDProcess g '(300 . 100))) => a process node (new-in DFDDataflow g n1 n2 '((200 . 50))) => a dataflow arc with one bend point (edit g) route Returns a list of points of the form (x . y) that represent where the given arc bends. The endpoints (where the arc attaches to the origin and destination nodes) are not included in the list, therefore it may be the case that route returns an empty list. Units are pixels. subdiagrams Returns a list of graphmodel instances that are children of the given graphobject instance. The returned list may be empty. See also parent-connection. master Returns the instance that serves as the master for the given object. The following expression will always be true: (memq self (views (master self))) where self is a graphobject instance and (not (nil? (master self))). paint-style Given a graphicscontext instance, returns a symbol representing the current pen drawing style ('solid or 'gray). This operation is useful primarily for writing user-defined DOME printer drivers (see appendix). See also paintcolor, paint. set-paint-style! Given a graphicscontext instance, sets the context's current paint style to the symbol argument. The argument is a symbol representing the current pen drawing style ('solid or 'gray). See also set-paint-color!. parent-connection Parent-connection is an operation defined on nodes and arcs that returns the corresponding object in the parent diagram (if any). For example, the parent-connection of a boundary point on a DFD graph is an arc whose destination is the process node being refined. In some cases, the parent-connection may be part of an archetype. incoming-arcs Given a node instance, the incoming-arcs operation returns a list of the arcs entering the node. See also outgoing-arcs. container The container operation is an inverse to the components method. Given a GrapEThing instance, it returns the object that contains it. The returned object may be a DoMENode, NetArc or GraphModel instance. See components. bounds Returns a rectangle (see "rectangle?") that represents the node's outer dimensions, including the name, if any. Units are pixels. border-bounds Returns a rectangle (list of the form ((x1 . y1) . (x2 . y2)) that is used as a starting point for drawing the object's outline. Units are pixels. set-border-bounds! Sets the rectangular border bounds of the given node to be the specified rectangle. See "rectangle?" for a specification of the representation of a rectangle. point? Answers #t if the argument is a point, #f otherwise. A point is either a two-element vector of the form #(x y), or a pair of the form (x . y), where x and y are both numbers. rectangle? Answers #t if the argument is a rectangle, #f otherwise. A rectangle is either a two-element vector whose first element is the upper-left point and second element is the lower-right point (i.e., #( #( ) #( ))), or a pair whose car is the upper left point and whose cdr is the lower right point (i.e., (( . ) . ( ))). Alter uses the convention that the x coordinates increase rightward, whereas y coordinates increase downward (as do screen coordinates). center Returns the point that lines at the center of the supplied rectangle. See "rectangle?" for a specification of how rectangles are represented. (center '((3 . 8) . (5 . 12))) => '(4 . 10) (center #(#(3 8) #(5 12))) => '(4 . 10) upper-left Returns the upper left corner of the rectangle (see "rectangle?"). (upper-left '((3 . 8) . (5 . 12))) => '(3 . 8) (upper-left #(#(3 8) #(5 12))) => #(3 8) lower-right Returns the lower right corner of the rectangle (see "rectangle?"). (lower-right '((3 . 8) . (5 . 12))) => '(5 . 12) (lower-right #(#(3 8) #(5 12))) => #(5 12) lower-left Returns the lower left corner of the rectangle (see "rectangle?"). (lower-left '((3 . 8) . (5 . 12))) => '(3 . 12) (lower-left #(#(3 8) #(5 12))) => '(3 . 12) upper-right Returns the upper right corner of the rectangle (see "rectangle?"). (upper-right '((3 . 8) . (5 . 12))) => '(5 . 8) (upper-right #(#(3 8) #(5 12))) => '(5 . 8) width Returns the width (in the x dimension) of the supplied rectangle (see "rectangle?"). (width '((3 . 8) . (5 . 12))) => 2 (width #(#(3 8) #(5 12))) => 2 height Returns the height (in the y dimension) of the supplied rectangle (see "rectangle?"). (height '((3 . 8) . (5 . 12))) => 4 (height #(#(3 8) #(5 12))) => 4 extent Returns the extent (a point whose x represents the width and whose y represents the height) of the supplied rectangle (see "rectangle?"). (extent '((3 . 8) . (5 . 12))) => '(2 . 4) expand-rectangle Returns a new rectangle which represents the given rectangle expanded by the specified expansion. The expansion may be specified as a number, a point or a rectangle. If it is a number, all sides of the rectangle are moved outward by the specified amount. If it is a point, then the left and right sides are expanded outward by the amount specified in the x component of the point, and the top and bottom sides are expanded outward by the amount specified in the y component of the point. If the expansion is a rectangle, then the left, top, right and bottom sides of the first argument are expanded by the amounts specified for the left, top, right and bottom of the expansion. (expand-rectangle '((3 . 8) . (5 . 12)) 1) => '((2 . 7) . (6 . 13)) (expand-rectangle '((3 . 8) . (5 . 12)) '(1 . 2)) => '((2 . 6) . (6 . 14)) (expand-rectangle '((3 . 8) . (5 . 12)) '((1 . 2) . (3 . 4)) => '((2 . 6) . (8 . 16)) translate-rectangle Returns a new rectangle which represents the given rectangle translated by the specified amount. The translation is specified as a point. (See "rectangle?"). The height and width of the new rectangle are the same as the argument. (translate-rectangle '((3 . 8) . (5 . 12)) '(1 . 2)) => '((4 . 10) . (6 . 14)) scale-rectangle Returns a new rectangle which represents the given rectangle scaled by the specified amount. The scale is specified as a point or number. (See "rectangle?"). (scale-rectangle '((3 . 8) . (5 . 12)) '(1 . 2)) => '((3 . 16) . (5 . 24)) (scale-rectangle '((3 . 8) . (5 . 12)) 5) => '((15 . 40) . (25 . 60)) graph Returns the graphmodel containing the object, if any. Returns nil if the object cannot be traced back to any graph. The graph of a graphmodel is itself. position Returns the absolute position (in pixels) of the given object as a point (x . y). relative-position Returns the relative position (in pixels) of the given node as a point (x . y). The returned value is relative to the object's container's position. If the container is a GraphModel instance, the container's position is taken to be (0 . 0). synchronize-display If the given graphmodel has an editor window open, synchronize-display brings it up to date by forcing all pending graphic operations to complete. The precise behavior of this operation is host-specific. add-method Adds the specified procedure as a handler for the method named in the interface argument. Alter's implementation of classes, operations and methods follows the OakLisp style, as presented in the OOPSLA '86 Proceedings. The detailed form of the arguments to add-method are as follows: (add-method (operation (receiver-class) . argument-list) . body) Add-method is a special form because the body and argument-list are not evaluated. However, the operation and receiver-class ARE evaluated. They are typically symbols bound to the objects of interest. This means, of course, that the operation must previously exist before add-method can be used to add to it (see find-operation, make). The argument-list is used to effectively build a procedure that also includes the body. This procedure is returned as the result of add-method. When the operation is called with an instance of the receiver-class (or a subclass) as the first argument, Alter will forward the call to the procedure. bindings Returns a list of pairs that represent the user-defined bindings within the active lexical environment. Each pair has a car that is a symbol, and a cdr that is the value bound to that symbol. Predefined procedures and operations are NOT included in this list (see 'predefined-bindings'). find-operation Find-operation is a special form. The argument is a symbol that is intended to be bound to an operation. Alter first checks the current lexical environment for a binding. If one exists and the value is an operation, Alter returns that value. If one exists and it is not an operation, an error occurs. If a user-defined binding does not exist, but a predefined binding does, Alter binds the symbol in the current lexical environment to a surrogate operation that allows the user to add methods without disrupting the space of predefined symbols; a surrogate handles calls just like a normal operation, except that it can forward calls to the predefined operation if it is given an object that falls outside of its interface range. If neither a user-defined or predefined binding exists, Alter creates a new operation and binds it to the given symbol. The return value of find-operation is the new or existing operation (or surrogate). See also add-method, make. (find-operation foo) => a new, normal operation (find-operation foo) => the same normal operation (find-operation length) => a new, surrogate operation (find-operation +) => error; a procedure make Creates an instance of the specified type. 'Make' is most useful for creating instances of type Operation, but can also be used for creating instances of GrapEThing and its subclasses (e.g., DoMENode, NetArc). See also add-method, find-operation. Alter's implementation of classes, operations and methods follows the OakLisp style, as presented in the OOPSLA '86 Proceedings. predefined-bindings Returns a list of pairs that represent the predefined bindings. Each pair has a car that is a symbol, and a cdr that is the value bound to that symbol. User-defined procedures and operations are NOT included in this list (see 'bindings'). flush Flushes any output that may have been buffered for the specified output port but not yet written to the device (either a file or window). The port is not closed. It is an error to apply flush to an output port that has already been closed. bits Returns a vector of integers representing the given image. The bitmap data is stored in the following format: * Pixels are stored in row-major order. Within a row, pixels are ordered by increasing X coordinates. * Rows are stored in top-to-bottom order (increasing Y coordinates). * Pixels are represented in chunky (Z) format, where the bits of a pixel are stored contiguously. * Rows are padded to multiples of 32-bits. The padding comes at the end of the row. * For pixels of size greater than eight bits, the pixel bytes are stored most-significant-first. * For pixels of size less than eight bits, pixels are ordered most-significant-bit-first. See also bits-per-pixel, palette, height, stride, width. bits-per-pixel Given an image instance, returns the number of bits required to represent a single pixel in the image. For a two-color image, the value 1 is returned. For a 256-color image, the value 8 is returned. height Returns the extent of the image in the y (vertical) direction. palette Returns an object representing the palette of the given image. See also colors, depth, maxindex, capacity. stride Returns the number of 32-bit integers needed to represent a single row in the given image. See also bits, bits-per-pixel, height. sort Return a new list that contains the same elements but ordered by the comparison procedure. The comparison procedure should accept two parameters and return #t if the first parameter should be ordered before the second, #f otherwise. (sort '(12 56 2 100 8) (lambda (a b) (<= a b))) => (2 8 12 56 100) (sort '(("foo" . 56) ("bar" . 100) ("zip" . 8)) (lambda (a b) (<= (cdr a) (cdr b)))) => (("zip" . 8) ("foo" . 56) ("bar" . 100)) (sort '(("foo" . 56) ("bar" . 100) ("zip" . 8)) (lambda (a b) (string<=? (car a) (car b)))) => (("bar" . 100) ("foo" . 56) ("zip" . 8)) Sort will fail to terminate if it is given a circular list. The sort procedure uses a quicksort algorithm. interface Given a procedure, interface returns a string representing its interface. Given an operation, interface returns a list of the classes that the operation is defined on. return-spec Returns a string representing the type of object typically returned by the given procedure. asbackup Transforms the given filename into a new filename that can be used as a backup copy. The transformation is platform-dependent. The new filename is not opened, and the file may already exist. See also asfilename. head Given a filename, head returns the directory component as a string. If the given filename corresponds to a directory, the return value represents the pathname of the parent directory (as a string). See also asfilename, tail, asbackup. tail Given a filename, tail returns the last component of it as a string. If the given filename corresponds to a file, the string returned represents the file only, without any directory information. If the given filename corresponds to a directory, the string returned represents the innermost directory, without any parent directory information. See also asfilename, head, asbackup. capacity Returns an integer representing the maximum number of colors that can be present in the given palette. This is usually a power of 2. See also palette, depth, colors. colors Returns a vector of color values that are present in the palette. Pixel values in an image correspond to the index positions in the color vector. See also bits, palette, maxindex. depth Returns an integer representing the number of bits needed to encode each pixel in the given image, the number of bits required to give each color in the given color palette a unique index. See also bits, palette, colors, capacity. max-index The highest index that can be used to access the color vector returned by the colors procedure. By definition, this is one less than capacity. identity Return the object from the registry that has the given identifier. register Add the object to the registry and return an identifier that may be used later for lookup. unregister Remove the identifier and its associated object from the registry. class? Returns true if the given object represents a grapething-class or one of its subclasses; returns false otherwise. (class? 5) => #f (class? integer-type) => #t (class? grapething) => #t (class? 'node) => #f (class? (make type '() '())) => #f dictionary? Returns true if the given object is a dictionary instance (see make-dictionary); returns false otherwise. color? Returns true if the given object is an instance of color-type; returns false otherwise. See palette, colors. directory? Returns true if the given filename instance corresponds to a directory on the host system. Returns false otherwise. Note: directory? may also return false if there is some component of the pathname that cannot be read. is-a? Returns #t if object is an instance of type or one of its subtypes. (is-a? object object-type) is always true. (is-a? object-type type) => #t (is-a? type object-type) => #t (is-a? operation type) => #t (is-a? is-a? procedure-type) => #t (is-a? is-a? type) => #f (is-a? (make object-type) type) => #f grape? Returns true if the given object is an instance of grapething or one of its many subclasses. Returns false otherwise. has-color? Returns false if the given palette instance has any non-gray colors. Returns true otherwise. has-gray-or-color? Returns false if the given palette instance is a two-color palette containing only black and white. Returns true otherwise. See also has-color?, palette, colors. nil? Returns true if the given object is eq? to the nil object (there is only one in Alter). Returns false otherwise. colbert-hierarchy Returns a colbcdgraph that represents the type hierarchy subtree rooted at the argument. all-subtypes Returns a list containing the argument, each of the argument's immediate subtypes and the elements contained in the result of applying all-subtypes to each of the argument's immediate subtypes with duplicates removed. subtypes Returns a list containing the argument and each of its immediate subtypes. supertypes Returns a list containing the argument's immediate supertypes. all-supertypes Returns a list containing each of the argument's immediate supertypes and the elements contained in the result of applying all-supertypes to each of the argument's immediate supertypes with duplicates removed. ^super This is just like (operation object . args) except that the method search begins at type rather that the type of object. It is required that type be an immediate supertype of the type that the method this call appears in is added to, although the current implementation does not yet enforce this restriction. ^super is analogous to the Smalltalk-80 mechanism of the same name, except that due to Alter's multiple inheritance it is necessary for the programmer to explicitly state which supertype is to be dispatched to. ivars Returns a list of symbols that represent the instance variables for the argument. all-ivars Returns a list of symbols that represent the instance variables for the argument and all of its supertypes. Equivalent to appending the results of calling ivars on the result of (cons type (all-supertypes type)). subtype? Returns #t if object is type or a subtype of type. In Alter types are subtypes of themselves. (subtype? type type) => #t (subtype? object-type type) => #f (subtype? type object-type) => #t (subtype operation object-type) => #t get-type Returns the type of the argument. (get-type object-type) => type (get-type (make object-type)) => object-type (get-type (make type '() '(object-type))) => type type? Returns true if the argument is a type. (type? type) => #t (type? object-type) => #t (type? (make object-type)) => #f (type? type?) => #f (type? operation) => #t (type? (make type '() '(object-type))) => #t object? Returns true for any Alter object. writable? Returns true if the given filename instance corresponds to a file that is writable by the user. Returns false otherwise. Note: there may be several reasons why the file is not writable, including problems in reading any component of the directory path. confirm Pops up a dialog window with two buttons. The window is labeled with the given string. The second and remaining arguments are optional. If the second argument is given, it must be a boolean indicating which button is to be the default (the one considered "pressed" if the user hits the Return key on the keyboard). The third argument, if present, is a string that is used as the label for the true-valued button. The fourth argument, if present, is a string that is used as the label for the false-valued button. Confirm returns a boolean value corresponding to the button that was chosen by the user. request-file-name Pops up a dialog window prompting the user to designate an existing file to use in a subsequent activity. Returns a filename, unless the user cancels the operation, in which case it returns nil. request-new-file-name Pops up a dialog window prompting the user to designate a new file to use in a subsequent activity. Returns a filename, unless the user cancels the operation, in which case it returns nil. user-choose Pops up a dialog window prompting the user to choose one element from a list, or to cancel the decision. The first argument is the string to serve as the message to prompt the user. The second argument is a list of strings used to label the various buttons that will be created. The third argument is a list of symbols, one for each button. One of these symbols will be returned, indicating which button was pressed. The fourth argument is a symbol that must match one of the symbols in the list given in the third argument, and specifies which button will be the default (the one considered "pressed" if the user hits the Return key). The fifth (optional) argument is a boolean value specifying whether or not to make the buttons all the same width, or to vary their widths depending on the string labels (default is to equalize the widths). user-choose-from-list Pops up a dialog window prompting the user to choose one element from a list, or to cancel the decision. The first argument is the string to serve as the message to prompt the user. The second argument is a list of strings used to label the items in the list. The third argument is a list of objects, one for each list item. One of these objects will be returned, indicating which item was selected. The fourth argument is an object that must match one of the objects in the list given in the third argument, and specifies which list item will be the default (the one initially selected when the dialog opens). The fifth argument is an object that is returned if the cancel button is pressed. The sixth (optional) argument is an integer value specifying the number of lines in the list to show at once. The seventh (optional) argument is another list of strings which serves as the labels for a set of additional buttons. The eighth (optional) argument must be included if the seventh argument is included. This argument is a list objects, one for each string in the seventh argument, that are returned when one of the additional buttons are pressed. warn Pops up a modal (dialog) window with the given message and a single button (labeled "OK") that the user must press (or, equivalently, hit the Return key) in order to continue with further DOME activity. category Given a procedure or operation, returns its category as a string. This category is where the procedure or operation can be found in the various browsers that are part of the Projector/Alter programming environment. If a second optional argument is given, it must be a string, and it is used to set the category of the procedure or operation. boolean? Boolean? returns #t if sexpr is either #t or #f and returns #f otherwise. (boolean? #f) => #t (boolean? 0) => #f (boolean? '()) => #f eqv? The eqv? procedure defines a useful equivalence relation on objects. Briefly, it returns #t if arg1 and arg2 should normally be regarded as the same object. This relation is left slightly open to interpretation, but the following partial specification of eqv? holds for all implementations of Scheme. The eqv? procedure returns #t if: arg1 and arg2 are both #t or both #f. arg1 and arg2 are both symbols and (string=? (symbol->string arg1) (symbol->string arg2)) => #t Note: This assumes that neither arg1 nor arg2 is an ``uninterned symbol''. arg1 and arg2 are both numbers, are numerically equal (see =), and are either both exact or both inexact. arg1 and arg2 are both characters and are the same character according to the char=? procedure both arg1 and arg2 are the empty list. arg1 and arg2 are pairs, vectors, or strings that denote the same locations in the store. arg1 and arg2 are procedures whose location tags are equal The eqv? procedure returns #f if: arg1 and arg2 are of different types one of arg1 and arg2 is #t but the other is #f arg1 and arg2 are symbols but (string=? (symbol->string arg1) (symbol->string arg2)) => #f one of arg1 and arg2 is an exact number but the other is an inexact number. arg1 and arg2 are numbers for which the = procedure returns #f. arg1 and arg2 are characters for which the char=? procedure returns #f. one of arg1 and arg2 is the empty list but the other is not. arg1 and arg2 are pairs, vectors, or strings that denote distinct locations. arg1 and arg2 are procedures that would behave differently (return a different value or have different side effects) for some arguments. (eqv? 'a 'a) => #t (eqv? 'a 'b) => #f (eqv? 2 2) => #t (eqv? '() '()) => #t (eqv? 100000000 100000000) => #t (eqv? (cons 1 2) (cons 1 2)) => #f (eqv? (lambda () 1) (lambda () 2)) => #f (eqv? #f 'nil) => #f (let ((p (lambda (x) x))) (eqv? p p)) => #t The following examples illustrate cases in which the above rules do not fully specify the behavior of eqv?. All that can be said about such cases is that the value returned by eqv? must be a boolean. (eqv? "" "") => unspecified (eqv? '#() '#()) => unspecified (eqv? (lambda (x) x) (lambda (x) x)) => unspecified (eqv? (lambda (x) x) (lambda (y) y)) => unspecified The next set of examples shows the use of eqv? with procedures that have local state. Gen-counter must return a distinct procedure every time, since each procedure has its own internal counter. Gen-loser, however, returns equivalent procedures each time, since the local state does not affect the value or side effects of the procedures. (define gen-counter (lambda () (let ((n 0)) (lambda () (set! n (+ n 1)) n)))) (let ((g (gen-counter))) (eqv? g g)) => #t (eqv? (gen-counter) (gen-counter)) => #f (define gen-loser (lambda () (let ((n 0)) (lambda () (set! n (+ n 1)) 27)))) (let ((g (gen-loser))) (eqv? g g)) => #t (eqv? (gen-loser) (gen-loser)) => unspecified (letrec ((f (lambda () (if (eqv? f g) 'both 'f))) (g (lambda () (if (eqv? f g) 'both 'g)))) (eqv? f g)) => unspecified (letrec ((f (lambda () (if (eqv? f g) 'f 'both))) (g (lambda () (if (eqv? f g) 'g 'both)))) (eqv? f g)) => #f Since it is an error to modify constant objects (those returned by literal expressions), implementations are permitted, though not required, to share structure between constants where appropriate. Thus the value of eqv? on constants is sometimes implementation-dependent. (eqv? '(a) '(a)) => unspecified (eqv? "a" "a") => unspecified (eqv? '(b) (cdr '(a b))) => unspecified (let ((x '(a))) (eqv? x x)) => #t The above definition of eqv? allows implementations latitude in their treatment of procedures and literals: implementations are free either to detect or to fail to detect that two procedures or two literals are equivalent to each other, and can decide whether or not to merge representations of equivalent objects by using the same pointer or bit pattern to represent both. not Not returns #t if obj is false, and returns #f otherwise. (not #t) => #f (not 3) => #f (not (list 3)) => #f (not #f) => #t (not '()) => #f (not (list)) => #f (not 'nil) => #f eq? Eq? is similar to eqv? except that in some cases it is capable of discerning distinctions finer than those detectable by eqv?. Eq? and eqv? are guaranteed to have the same behavior on symbols, booleans, the empty list, pairs, and non-empty strings and vectors. Eq?'s behavior on numbers and characters is implementation-dependent, but it will always return either true or false, and will return true only when eqv? would also return true. Eq? may also behave differently from eqv? on empty vectors and empty strings. (eq? 'a 'a) => #t (eq? '(a) '(a)) => unspecified (eq? (list 'a) (list 'a)) => #f (eq? "a" "a") => unspecified (eq? "" "") => unspecified (eq? '() '()) => #t (eq? 2 2) => unspecified (eq? #\A #\A) => unspecified (eq? car car) => #t (let ((n (+ 2 3))) (eq? n n)) => unspecified (let ((x '(a))) (eq? x x)) => #t (let ((x '#())) (eq? x x)) => #t (let ((p (lambda (x) x))) (eq? p p)) => #t equal? Equal? recursively compares the contents of pairs, vectors, and strings, applying eqv? on other objects such as numbers and symbols. A rule of thumb is that objects are generally equal? if they print the same. Equal? may fail to terminate if its arguments are circular data structures. (equal? 'a 'a) => #t (equal? '(a) '(a)) => #t (equal? '(a (b) c) '(a (b) c)) => #t (equal? "abc" "abc") => #t (equal? 2 2) => #t (equal? (make-vector 5 'a) (make-vector 5 'a)) => #t (equal? (lambda (x) x) (lambda (y) y)) => unspecified pair? Pair? returns #t if sexpr is a pair, and otherwise returns #f. If (list? foo) is true, then (pair? foo) will be true. (pair? '(a . b)) => #t (pair? '(a b c)) => #t (pair? '()) => #f (pair? '#(a b)) => #f flatten Returns a list whose members are those elements that are either atoms or members of the result of applying flatten to an element that is a list. cons Returns a newly allocated pair whose car is obj1 and whose cdr is obj2. The pair is guaranteed to be different (in the sense of eqv?) from every existing object. (cons 'a '()) => (a) (cons '(a) '(b c d)) => ((a) b c d) (cons "a" '(b c)) => ("a" b c) (cons 'a 3) => (a . 3) (cons '(a b) 'c) => ((a b) . c) car Returns the contents of the car field of the pair. Note that it is an error to take the car of the empty list. (car '(a b c)) => a (car '((a) b c d)) => (a) (car '(1 . 2)) => 1 (car '()) => error x Returns the x-coordinate of a point (see "point?"). (x '(3 . 9)) => 3 (x #(2.5 7)) => 2.5 y Returns the y-coordinate of a point (see "point?"). (y '(3 . 9)) => 9 (y #(2.5 7)) => 7 cdr Returns the contents of the cdr field of the pair. Note that it is an error to take the cdr of the empty list. (cdr '((a) b c d)) => (b c d) (cdr '(1 . 2)) => 2 (cdr '()) => error set-car! Stores arg in the car field of the pair. The value returned by set-car! is unspecified. (define f (list 'not-a-constant-list)) (define g '(constant-list)) (set-car! f 3) => unspecified (set-car! g 3) => error set-cdr! Stores arg in the cdr field of pair. The value returned by set-cdr! is unspecified. caar Equivalent to (car (car obj)). Alter provides procedures up to 4 deep (e.g., cadaar) which mix together car and cdr. There are 28 such procedures. (caar '((a b) c)) => 'a (cdar '((a b) c)) => 'b (cadr '((a b) c)) => 'c (cadddr '(a b c d e f) => 'd null? Returns #t if sexpr is the empty list, otherwise returns #f. list? Returns #t if sexpr is a list, otherwise returns #f. By definition, all lists have finite length and are terminated by the empty list. For this reason, it may take list? a fair amount of time to determine its answer if given a very long list. (list? '(a b c)) => #t (list? '()) => #t (list? '(a . b)) => #f (let ((x (list 'a))) (set-cdr! x x) (list? x)) => #f list Returns a newly allocated list of its arguments. (list 'a (+ 3 4) 'c) => (a 7 c) (list) => () length Length is an operation in Alter, defined on strings, vectors and lists. (This is an extension to Scheme R4, which specifies 'length' as a procedure defined only on lists.) For strings, length behaves exactly like string-length. For vectors, length behaves exactly like vector-length. (length "abcde") => 5 (length #(1 2 3)) => 3 For lists, length returns the number of topmost cells in the argument list, as the following examples illustrate. (length '(a b c)) => 3 (length '(a (b) (c d e))) => 3 (length '()) => 0 append Append is an operation defined on both strings and lists. (This is an extension to Scheme R4, which defines append as a procedure defined only on lists.) Given list arguments, append returns a list consisting of the elements of the first argument list followed by the elements of the remaining argument lists. Given string arguments, append returns a string consisting of the elements of the first string followed by the elements of the remaining string arguments. (append '(x) '(y)) => (x y) (append '(a) '(b c d)) => (a b c d) (append '(a (b)) '((c))) => (a (b) (c)) (append "a" "bcd") => "abcd" The resulting list or string is always newly allocated, except that in the case of lists, the result shares structure with the last list argument. With lists, the last argument may actually be any object; an improper list results if the last argument is not a proper list. (append '(a b) '(c . d)) => (a b c . d) (append '() 'a) => a reverse Returns a newly allocated list consisting of the elements of list in reverse order. (reverse '(a b c)) => (c b a) (reverse '(a (b c) d (e (f)))) => ((e (f)) d (b c) a) list-ref Returns the kth element of list. (This is the same as the car of (list-tail list k).) (list-ref '(a b c d) 2) => c (list-ref '(a b c d) (inexact->exact (round 1.8))) => c list-last Returns the last element of list. (This is the same as (list-ref list (- (length list) 1)).) (list-ref '(a b c d)) => d (list-ref '()) => nil list-head Returns a copy of the list including only the first k elements. List-tail could be defined by (define list-head (lambda (x k) (if (or (zero? k) (null? x)) (list) (set-cdr! (list (car x)) (list-head (cdr x) (- k 1)))))) list-tail Returns the sublist of list obtained by omitting the first k elements. List-tail could be defined by (define list-tail (lambda (x k) (if (zero? k) x (list-tail (cdr x) (- k 1))))) memq This procedure returns the first sublist of list whose car is obj, where the sublists of list are the non-empty lists returned by (list-tail list k) for k less than the length of list. If obj does not occur in list, then #f (not the empty list) is returned. Memq uses eq? to compare obj with the elements of list. See also memv, member. (memq 'a '(a b c)) => (a b c) (memq 'b '(a b c)) => (b c) (memq 'a '(b c d)) => #f (memq (list 'a) '(b (a) c)) => #f (memq 101 '(100 101 102)) => unspecified memv This procedure returns the first sublist of list whose car is obj, where the sublists of list are the non-empty lists returned by (list-tail list k) for k less than the length of list. If obj does not occur in list, then #f (not the empty list) is returned. Memv uses eqv? to compare obj with the elements of list. See also memq, member. (memv 101 '(100 101 102)) => (101 102) member This procedure returns the first sublist of list whose car is obj, where the sublists of list are the non-empty lists returned by (list-tail arg2 k) for k less than the length of list. If obj does not occur in list, then #f (not the empty list) is returned. Member uses equal? to compare arg with the elements of list. See also memq, memv. (member (list 'a) '(b (a) c)) => ((a) c) assq This procedure finds the first pair in list whose car field is obj, and returns that pair. If no pair in list has obj as its car, then #f (not the empty list) is returned. Assq uses eq? to compare arg1 with the car fields of the pairs in list. See also assv, assoc. (define e '((a 1) (b 2) (c 3))) (assq 'a e) => (a 1) (assq 'b e) => (b 2) (assq 'd e) => #f (assq (list 'a) '(((a)) ((b)) ((c)))) => #f (assq 5 '((2 3) (5 7) (11 13))) => unspecified assv This procedure finds the first pair in list whose car field is obj, and returns that pair. If no pair in list has obj as its car, then #f (not the empty list) is returned. Assv uses eqv? to compare arg1 with the car fields of the pairs in list. See also assq, assoc. (assv 5 '((2 3) (5 7) (11 13))) => (5 7) assoc This procedure finds the first pair in list whose car field is obj, and returns that pair. If no pair in list has obj as its car, then #f (not the empty list) is returned. Assoc uses equal? to compare arg1 with the car fields of the pairs in list. See also assq, assv. (assoc (list 'a) '(((a)) ((b)) ((c)))) => ((a)) symbol? Returns #t if sexpr is a symbol, otherwise returns #f. (symbol? 'foo) => #t (symbol? (car '(a b))) => #t (symbol? "bar") => #f (symbol? 'nil) => #t (symbol? '()) => #f (symbol? #f) => #f symbol->string Returns the name of symbol as a string. If the symbol was part of an object returned as the value of a literal expression or by a call to the read procedure, and its name contains alphabetic characters, then the string returned will contain characters in the implementation's preferred standard case---some implementations will prefer upper case, others lower case. If the symbol was returned by string->symbol, the case of characters in the string returned will be the same as the case in the string that was passed to string->symbol. It is an error to apply mutation procedures like string-set! to strings returned by this procedure. The following examples assume that the implementation's standard case is lower case: (symbol->string 'flying-fish) => "flying-fish" (symbol->string 'Martin) => "martin" (symbol->string (string->symbol "Malvina")) => "Malvina" string->symbol Returns the symbol whose name is arg. This procedure can create symbols with names containing special characters or letters in the non-standard case, but it is usually a bad idea to create such symbols because in some implementations of Scheme they cannot be read as themselves. See symbol->string. The following examples assume that the implementation's standard case is lower case: (eq? 'mISSISSIppi 'mississippi) => #t (string->symbol "mISSISSIppi") => the symbol with name "mISSISSIppi" (eq? 'bitBlt (string->symbol "bitBlt")) => #f (eq? 'JollyWog (string->symbol (symbol->string 'JollyWog))) => #t (string=? "K. Harper, M.D." (symbol->string (string->symbol "K. Harper, M.D."))) => #t number? Number? can be applied to any kind of argument, including non-numbers. It returns #t if the object is a number, and otherwise it returns #f. (number? 'a) => #f (number? 3) => #t (number? 3.1415) => #t complex? Complex? can be applied to any kind of argument, including non-numbers. It returns #t if the object is a complex number, and otherwise it returns #f. If z is an inexact complex number, then (real? z) is true if and only if (zero? (imag-part z)) is true. (complex? 3+4i) => #t (complex? 3) => #t See also number?, real?, rational? and integer? real? Real? can be applied to any kind of argument, including non-numbers. It returns #t if the object is a real number, and otherwise it returns #f. If real? is true of a number then all higher type predicates are also true of that number. Consequently, if real? is false of a number, then all lower type predicates are also false of that number. If z is an inexact complex number, then (real? z) is true if and only if (zero? (imag-part z)) is true. If x is an inexact real number, then (integer? x) is true if and only if (= x (round x)). (real? 3) => #t (real? -2.5+0.0i) => #t (real? #e1e10) => #t See also number?, complex?, rational? and integer?. rational? Rational? can be applied to any kind of argument, including non-numbers. It returns #t if the object is a rational, and otherwise it returns #f. If rational? is true of a number then all higher type predicates are also true of that number. Consequently, if rational? is false of a number, then all lower type predicates are also false of that number. (rational? (/ 6 10)) => #t (rational? (/ 6 3)) => #t The behavior of rational? on inexact numbers is unreliable, since any inaccuracy may affect the result. See also number?, complex?, real? and integer?. integer? Integer? can be applied to any kind of argument, including non-numbers. It returns #t if the object is an integer, and otherwise it returns #f. If integer? is true of a number then all higher type predicates are also true of that number. Consequently, if integer? is false of a number, then all lower type predicates are also false of that number. If x is an inexact real number, then (integer? x) is true if and only if (= x (round x)). (integer? 3.0) => #t (integer? 8/4) => #t The behavior of integer? on inexact numbers is unreliable, since any inaccuracy may affect the result. See also number?, complex?, real?, and rational? bound? Returns #t if the symbol is bound to a value in the current lexical environment, otherwise returns #f. exact? Exact? provides a test for the exactness of a quantity. For any Alter number, either exact? or inexact? is true, but not both. inexact? Exact? provides a test for the exactness of a quantity. For any Alter number, either exact? or inexact? is true, but not both. = This procedures returns #t if its arguments are equal. = is transitive. The traditional implementations of = in Lisp-like languages are not transitive. While it is not an error to compare inexact numbers using =, the results may be unreliable because a small inaccuracy may affect the result; this is especially true of =. < This procedures returns #t if its arguments are monotonically increasing. < is transitive. The traditional implementations of < in Lisp-like languages are not transitive. While it is not an error to compare inexact numbers using <, the results may be unreliable because a small inaccuracy may affect the result. > This procedures returns #t if its arguments are monotonically decreasing. > is transitive. The traditional implementations of > in Lisp-like languages are not transitive. While it is not an error to compare inexact numbers using >, the results may be unreliable because a small inaccuracy may affect the result. <= This procedures returns #t if its arguments are monotonically nondecreasing. <= is transitive. The traditional implementations of <= in Lisp-like languages are not transitive. While it is not an error to compare inexact numbers using <=, the results may be unreliable because a small inaccuracy may affect the result. >= This procedure returns #t if its arguments are monotonically nonincreasing. >= is transitive. The traditional implementations of >= in Lisp-like languages are not transitive. While it is not an error to compare inexact numbers using >=, the results may be unreliable because a small inaccuracy may affect the result. zero? This procedure returns #t if its argument is exactly equal to zero. The result for inexact numbers may be unreliable because of small inaccuracies. positive? This procedure returns #t if its argument is greater than zero. The result for inexact numbers may be unreliable because of small inaccuracies. negative? This procedure returns #t if its argument is less than zero. The result for inexact numbers may be unreliable because of small inaccuracies. even? This procedure returns #t if its argument is even (a multiple of 2). The result for inexact numbers may be unreliable because of small inaccuracies. odd? This procedure returns #t if its argument is odd (exactly halfway between two adjacent multiples of 2). The result for inexact numbers may be unreliable because of small inaccuracies. max This procedure returns the maximum of its arguments. (max 3 4) => 4 ; exact (max 3 4.1) => 4.1 ; inexact min This procedure returns the minimum of its arguments. (min 3 4) => 3 ; exact (min 3.9 4) => 3.9 ; inexact If any argument is inexact, then the result will also be inexact. If min is used to compare numbers of mixed exactness, and the numerical value of the result cannot be represented as an inexact number without loss of accuracy, then the procedure may report a violation of an implementation restriction. + This procedure returns the sum of its arguments. This procedure is exactness preserving. (+ 3 4) => 7 (+ 3 4.0) => 7.0 (+ 3) => 3 (+) => 0 point+ This procedure returns the sum of its arguments, where the first argument is a point and the rest of the arguments are points or numbers. See "point?" for an explanation of how points are represented in Alter. (point+ '(1 . 2) '(3 . 4)) => '(4 . 6) (point+ #(1 2) #(3 4)) => #(4 6) (point+ '(1 . 2) 3 4) => '(8 . 9) (point+ #(1 2) 3 4) => #(8 9) point- This procedure returns the difference of its arguments, where the first argument is a point and the rest of the arguments are points or numbers. See "point?" for an explanation of how points are represented in Alter. (point+ '(5 . 2) '(3 . 4)) => '(2 . -2) (point- #(5 2) #(3 4)) => #(2 -2) (point- '(5 . 2) 3 4) => '(-2 . -5) (point- #(5 2) 3 4) => #(-2 -5) point* This procedure returns the product of its argument points. See "point?" for an explanation of how points are represented in Alter. (point* '(5 . 2) '(3 . 4)) => '(15 . 8) (point* #(5 2) #(3 4)) => #(15 8) (point* '(5 . 2) 3) => '(15 . 6) (point* #(5 2) 4 '(1 . 2)) => #(20 16) point/ This procedure returns the quotient of its argument points. See "point?" for an explanation of how points are represented in Alter. (point/ '(6 . 2) '(3 . 2)) => '(2 . 1) (point/ #(6 2) #(3 2)) => #(2 1) (point/ '(16 . 32) 4) => '(4 . 8) (point/ #(40 40) 4 '(1 . 2)) => #(10 5) point> Returns #t if both the x and y coordinates of the first point are greater than the x and y coordinates of the second point (see "point?"). Otherwise returns #f. (point> '(3 . 2) '(2 . 2)) => #f (point> '(3 . 2) '(2 . 1)) => #t point>= Returns #t if both the x and y coordinates of the first point are greater than or equal to the x and y coordinates of the second point (see "point?"). Otherwise returns #f. (point>= '(3 . 2) '(2 . 2)) => #t (point>= '(3 . 2) '(2 . 3)) => #f point< Returns #t if both the x and y coordinates of the first point are less than the x and y coordinates of the second point (see "point?"). Otherwise returns #f. (point< '(3 . 2) '(4 . 5)) => #t (point< '(3 . 2) '(2 . 2)) => #f point<= Returns #t if both the x and y coordinates of the first point are less than or equal to the x and y coordinates of the second point (see "point?"). Otherwise returns #f. (point<= '(3 . 2) '(4 . 2)) => #t (point<= '(3 . 2) '(3 . 1)) => #f point-min Returns the upper left corner of the rectangle that contains all of the points passed as arguments. (point-min '(2 . 2) '(1 . 3)) => '(1 . 2) (point-min #(3 2) #(3 1) #(2 4)) => '(2 . 1) point-max Returns the lower right corner of the rectangle that contains all of the points passed as arguments. (point-min '(2 . 2) '(1 . 3)) => '(2 . 3) (point-min #(3 2) #(3 1) #(2 4)) => '(3 . 4) * This procedure return the product of its arguments. This procedure is exactness preserving. (* 2 17.5) => 35.0 (* 4) => 4 (*) => 1 - With two or more arguments, this procedure returns the difference of its arguments, associating to the left. With one argument, however, it returns the additive inverse of its argument. This procedure is exactness preserving. (- 3 4) => -1 (- 3 4 5) => -6 (- 3) => -3 / With two or more arguments, this procedure returns the quotient of its arguments, associating to the left. With one argument, however, it returns the multiplicative inverse of its argument. This procedure is exactness preserving, except that division may coerce its result to inexact in implementations that do not support ratnums. (/ 3 4 5) => 3/20 (/ 3) => 1/3 (/ 1.5 3) => 0.5 abs Abs returns the magnitude of its argument. Abs is exactness preserving when its argument is real. (abs -7) => 7 quotient This exactness-preserving procedure implements number-theoretic (integer) division: For positive integers n1 and n2, if n3 and n4 are integers such that n1=n2*n3+n4 and 0 <= n4 < n2, then (quotient n1 n2) => n3 For integers n1 and n2 with n2 not equal to 0, (= n1 (+ (* n2 (quotient n1 n2)) (remainder n1 n2))) => #t provided all numbers involved in that computation are exact. The value returned by quotient always has the sign of the product of its arguments. remainder This exactness-preserving procedure implements number-theoretic (integer) division: For positive integers n1 and n2, if n3 and n4 are integers such that n1=n2*n3+n4 and 0 <= n4 < n2, then (remainder n1 n2) => n4 For integers n1 and n2 with n2 not equal to 0, (= n1 (+ (* n2 (quotient n1 n2)) (remainder n1 n2))) => #t provided all numbers involved in that computation are exact. Remainder and modulo differ on negative arguments---the remainder is either zero or has the sign of the dividend, while the modulo always has the sign of the divisor: (remainder 13 4) => 1 (modulo -13 4) => 3 (remainder -13 4) => -1 (remainder 13 -4) => 1 (remainder -13 -4) => -1 (remainder -13 -4.0) => -1.0 ; inexact modulo This exactness-preserving procedure implement number-theoretic (integer) division: For positive integers n1 and n2, if n3 and n4 are integers such that n1=n2*n3+n4 and 0 <= n4 < n2, then (modulo n1 n2) => n4 provided all numbers involved in that computation are exact. Remainder and modulo differ on negative arguments---the remainder is either zero or has the sign of the dividend, while the modulo always has the sign of the divisor: (modulo 13 4) => 1 (remainder 13 4) => 1 (modulo -13 4) => 3 (modulo 13 -4) => -3 (modulo -13 -4) => -1 gcd This procedure returns the greatest common divisor of its arguments. The result is always non-negative. This procedure is exactness preserving. (gcd 32 -36) => 4 (gcd) => 0 lcm This procedure returns the greatest least common multiple of its arguments. The result is always non-negative. This procedure is exactness preserving. (lcm 32 -36) => 288 (lcm 32.0 -36) => 288.0 ; inexact (lcm) => 1 numerator This procedure returns the numerator of its argument; the result is computed as if the argument was represented as a fraction in lowest terms. The denominator is always positive. (numerator (/ 6 4)) => 3 denominator This procedure returns the denominator of its argument; the result is computed as if the argument was represented as a fraction in lowest terms. The denominator is always positive. The denominator of 0 is defined to be 1. (denominator (/ 6 4)) => 2 (denominator (exact->inexact (/ 6 4))) => 2.0 floor Floor returns the largest integer not larger than number. The result is always exact. (floor -4.3) => -5 (floor 3.5) => 3 ceiling Ceiling returns the smallest integer not smaller than number. The result is always exact. (ceiling -4.3) => -4 (ceiling 3.5) => 4 truncate Truncate returns the integer closest to number whose absolute value is not larger than the absolute value of number. The result is always exact. (truncate -4.3) => -4 (truncate 3.5) => 3 round Round returns the closest integer to number, rounding to even when number is halfway between two integers. Round rounds to even for consistency with the default rounding mode specified by the IEEE floating point standard. The result is always exact. (round -4.3) => -4 (round 3.5) => 4 (round 7/2) => 4 (round 7) => 7 rationalize Rationalize returns the simplest rational number differing from arg1 by no more than arg2. A rational number r1 is simpler than another rational number r2 if r1 = p1/q1 and r2 = p2/q2 (in lowest terms) and |p1| <= |p2| and |q1| <= |q2|. Thus 3/5 is simpler than 4/7. Although not all rationals are comparable in this ordering (consider 2/7 and 3/5) any interval contains a rational number that is simpler than every other rational number in that interval (the simpler 2/5 lies between 2/7 and 3/5). Note that 0 = 0/1 is the simplest rational of all. (rationalize (inexact->exact .3) 1/10) => 1/3 ; exact (rationalize .3 1/10) => 1/3 ; inexact exp Exp computes e^number. The result is a real number. log Log computes the natural logarithm of arg (not the base ten logarithm). sin This procedure computes the usual transcendental function. cos This procedure computes the usual transcendental function. tan This procedure computes the usual transcendental function. asin This procedure computes the usual transcendental function. acos This procedure computes the usual transcendental function. atan This procedure computes the usual transcendental function. sqrt Returns the principal square root of number. The result will have either positive real part, or zero real part and non-negative imaginary part. expt Returns base raised to the power exponent: number^exponent = e^(exponent log base). 0^0 is defined to be equal to 1. theta Returns the angular component (in radians) of the ray represented by the given point (see "point?"). (theta '(2 . 0)) => 0.0 (theta '(5 . 5)) => 0.785398 (theta '(-1 . 3)) => 1.89255 (theta '(2 . -2)) => 5.49779 approximate Returns an approximation to arg in a representation whose precision is the same as that of the representation of arg, which must be an inexact number. The result is always inexact. (approximate 3.1415926535 1F10) => 3.14159F0 (approximate 3.1415926535 #I65535) => #I3 (approximate 3.14F0 1L8) => 3.14L0 (approximate 3.1415926535F0 1L8) => 3.14159L0 make-rectangular Suppose x1, x2, x3, and x4 are real numbers and z is a complex number such that z = x1 + x2 i = x3 . e^(i x4) Then make-rectangular returns z. See also make-polar, real-part, imag-part, angle and magnitude. make-polar Suppose x1, x2, x3, and x4 are real numbers and z is a complex number such that z = x1 + x2 i = x3 . e^(i x4) Then make-polar returns z. real-part Suppose x1, x2, x3, and x4 are real numbers and z is a complex number such that z = x1 + x2 i = x3 . e^(i x4) Then real-part returns x1. imag-part Suppose x1, x2, x3, and x4 are real numbers and z is a complex number such that z = x1 + x2 i = x3 . e^(i x4) Then imag-part returns x2. magnitude Suppose x1, x2, x3, and x4 are real numbers and z is a complex number such that z = x1 + x2 i = x3 . e^(i x4) Then magnitude returns x3. Magnitude is the same as abs for a real argument, but abs must be present in all implementations, whereas magnitude need only be present in implementations that support general complex numbers. angle Suppose x1, x2, x3, and x4 are real numbers and z is a complex number such that z = x1 + x2 i = x3 . e^(i x4) Then angle returns x4. In the case of angle, whose value is not uniquely determined by the preceding rule, the value returned will be the one in the range -pi (exclusive) to pi (inclusive). exact->inexact Exact->inexact returns an inexact representation of arg. The value returned is the inexact number that is numerically closest to the argument. For exact arguments which have no reasonably close inexact equivalent, Alter may signal an error. This procedure implements the natural one-to-one correspondence between exact and inexact integers throughout an implementation-dependent range. inexact->exact Inexact->exact returns an exact representation of arg. The value returned is the exact number that is numerically closest to the argument. For inexact arguments which have no reasonably close exact equivalent, Alter may signal an error. This procedure implements the natural one-to-one correspondence between exact and inexact integers throughout an implementation-dependent range. random Returns a random number. With no arguments, the returned value is a floating point number evenly distributed between 0.0 and 1.0. With two integer arguments, the returned value is an integer evenly distributed between the two given values (inclusive). The first argument must be less than the second argument. number->string Radix must be an exact integer, either 2, 8, 10, or 16. If omitted, radix defaults to 10. The procedure number->string takes a number and a radix and returns as a string an external representation of the given number in the given radix such that (let ((number n) (radix r)) (eqv? n (string->number (number->string n r) r))) is true. It is an error if no possible result makes this expression true. If n is inexact, the radix is 10, and the above expression can be satisfied by a result that contains a decimal point, then the result contains a decimal point and is expressed using the minimum number of digits (exclusive of exponent and trailing zeroes) needed to make the above expression true; otherwise the format of the result is unspecified. The result returned by number->string never contains an explicit radix prefix. The error case can occur only when n is not a complex number or is a complex number with a non-rational real or imaginary part. object->string Returns a string representation of sexpr by the same mechanism that display formulates a string to display. c.f. display. string->number Returns a number of the maximally precise representation expressed by the given string. Radix must be an exact integer, either 2, 8, 10, or 16. If supplied, radix is a default radix that may be overridden by an explicit radix prefix in string (e.g. "#o177"). If radix is not supplied, then the default radix is 10. If string is not a syntactically valid notation for a number, then string->number returns #f. (string->number "100") => 100 (string->number "100" 16) => 256 (string->number "1e2") => 100.0 Although string->number is an essential procedure, an implementation may restrict its domain in the following ways. String->number is permitted to return #f whenever string contains an explicit radix prefix. If all numbers supported by an implementation are real, then string->number is permitted to return #f whenever string uses the polar or rectangular notations for complex numbers. If all numbers are integers, then string->number may return #f whenever the fractional notation is used. If all numbers are exact, then string->number may return #f whenever an exponent marker or explicit exactness prefix is used, or if a # appears in place of a digit. If all inexact numbers are integers, then string->number may return #f whenever a decimal point is used. char? Returns #t if sexpr is a character, otherwise returns #f. char=? Returns #t if the two arguments represent the same character. char? Returns #t if the character represented by the first argument follows the character represented by the second argument, assuming a total ordering on the set of characters. char<=? Returns #t if the character represented by the first argument is the same as or precedes the character represented by the second argument, assuming a total ordering on the set of characters. char>=? Returns #t if the character represented by the first argument is the same as or follows the character represented by the second argument, assuming a total ordering on the set of characters. char-ci=? This procedure is similar to char=?, but treats upper case and lower case letters as the same. For example, (char-ci=? #\A #\a) returns #t. char-ci? This procedure is similar to char>?, but treats upper case and lower case letters as the same. For example, (char-ci>? #\A #\b) returns #t, whereas (char>? #\A #\b) returns #f. char-ci<=? This procedure is similar to char<=?, but treats upper case and lower case letters as the same. For example, (char-ci<=? #\a #\B) returns #t, whereas (char<=? #\a #\B) returns #f. char-ci>=? This procedure is similar to char>=?, but treats upper case and lower case letters as the same. For example, (char-ci>=? #\a #\B) returns #t, whereas (char>=? #\a #\B) returns #f. char-alphabetic? This procedure returns #t if its argument is alphabetic, otherwise it returns #f. The alphabetic characters are the 52 upper and lower case letters. See also char-numeric?, char-whitespace?, char-upper-case? and char-lower-case?. char-numeric? This procedure returns #t if its argument is numeric, otherwise it returns #f. The numeric characters are the ten decimal digits. See also char-alphabetic?, char-whitespace?, char-upper-case? and char-lower-case?. char-whitespace? This procedure returns #t if its argument is whitespace, otherwise it returns #f. The whitespace characters are space, tab, line feed, form feed and carriage return. See also char-alphabetic?, char-numeric?, char-upper-case? and char-lower-case? char-upper-case? This procedure returns #t if its argument is upper case, otherwise it returns #f. The alphabetic characters are the 52 upper and lower case letters. See also char-whitespace?, char-numeric?, char-whitespace? and char-lower-case? char-lower-case? The procedures return #t if its argument is a lower case character, otherwise it returns #f. The alphabetic characters are the 52 upper and lower case letters. See also char-whitespace?, char-numeric?, char-whitespace? and char-upper-case?. char->integer Given a character, char->integer returns an exact integer representation of the character. This procedure implements an injective order isomorphism between the set of characters under the char<=? ordering and some subset of the integers under the <= ordering. That is, if (char<=? a b) => #t, and (<= x y) => #t and x and y are in the domain of integer->char, then (<= (char->integer a) (char->integer b)) => #t integer->char Given an exact integer that is the image of a character under char->integer, integer->char returns that character. This procedure implements an injective order isomorphism between the set of characters under the char<=? ordering and some subset of the integers under the <= ordering. That is, if (char<=? a b) => #t, and (<= x y) => #t and x and y are in the domain of integer->char, then (char<=? (integer->char x) (integer->char y)) => #t char-upcase This procedure returns a character c such that (char-ci=? char c) is true. In addition, if char is alphabetic, then the result of char-upcase is upper case. See also char-downcase. char-downcase This procedure return a character c such that (char-ci=? char c) is true. In addition, if char is alphabetic, then the result of char-downcase is lower case. See also char-upcase. string-upcase This procedure returns a string of equal length to the argument string such that char-ci=? is true for each corresponding character of the argument and the result. In addition, if a given character in the argument string is alphabetic, the corresponding character in the result string is upper case. See also string-downcase. string-downcase This procedure returns a string of equal length to the argument string such that char-ci=? is true for each corresponding character of the argument and the result. In addition, if a given character in the argument string is alphabetic, the corresponding character in the result string is lower case. See also string-upcase. string-capitalize This procedure returns a string of equal length to the argument string such that the first character of the string is now uppercase (char-ci=? is true). string? Returns #t if sexpr is a string, otherwise returns #f. make-string Make-string returns a newly allocated string of the specified length. If char is given, then all elements of the string are initialized to char, otherwise the contents of the string are unspecified. string Returns a newly allocated string composed of the arguments. string-length Returns the number of characters in the given string. See also length. string-ref String-ref returns the indexth character of string using zero-origin indexing. string-set! String-set! stores char in the indexth position of string and returns an unspecified value. String-set! uses zero-origin indexing. (define (f) (make-string 3 \#*)) (define (g) "***") (string-set! (f) 0 #\?) => unspecified (string-set! (g) 0 #\?) => error (string-set! (symbol->string 'immutable) 0 #\?) => error string-empty? Returns #t if the string is the empty string. (string-empty? "abc") => #f (string-empty? "") => #t string=? Returns #t if the two strings are the same length and contain the same characters in the same positions, otherwise returns #f. String=? treats upper and lower case as distinct characters. See also string-ci=?. (string=? "abc" (string #\a #\b #\c)) => #t (string=? "ABC" "abc") => #f string-ci=? Returns #t if the two strings are the same length and contain the same characters in the same positions, otherwise returns #f. String-ci=? treats upper and lower case letters as though they were the same character. See string=?. (string-ci=? "abc" (string #\a #\b #\c)) => #t (string-ci=? "ABC" "abc") => #t (string-ci=? "ab" "AbC") => #f string? This procedure is a lexicographic extension to strings of the corresponding ordering on characters. String>? is the lexicographic ordering on strings induced by the ordering char>? on characters. If two strings differ in length but are the same up to the length of the shorter string, the longer string is considered to be lexicographically greater than the longer string. string<=? This procedure is a lexicographic extension to strings of the corresponding ordering on characters. String<=? is the lexicographic ordering on strings induced by the ordering char<=? on characters. If two strings differ in length but are the same up to the length of the shorter string, the shorter string is considered to be lexicographically less than the longer string. string>=? This procedure is a lexicographic extension to strings of the corresponding ordering on characters. String>=? is the lexicographic ordering on strings induced by the ordering char>=? on characters. If two strings differ in length but are the same up to the length of the shorter string, the longer string is considered to be lexicographically greater than the longer string. string-ci? This procedure is a lexicographic extension to strings of the corresponding ordering on characters. String-ci>? is the lexicographic ordering on strings induced by the ordering char-ci>? on characters. If two strings differ in length but are the same up to the length of the shorter string, the longer string is considered to be lexicographically greater than the longer string. string-ci<=? This procedure is a lexicographic extension to strings of the corresponding ordering on characters. String-ci<=? is the lexicographic ordering on strings induced by the ordering char-ci<=? on characters. If two strings differ in length but are the same up to the length of the shorter string, the shorter string is considered to be lexicographically less than the longer string. string-ci>=? This procedure is a lexicographic extension to strings of the corresponding ordering on characters. String-ci>=? is the lexicographic ordering on strings induced by the ordering char-ci>=? on characters. If two strings differ in length but are the same up to the length of the shorter string, the longer string is considered to be lexicographically greater than the longer string. substring Substring returns a newly allocated string formed from the characters of string beginning with index start (inclusive) and ending with index end (exclusive). (substring "abcdefg" 2 4) => "cd" (substring "abc" 2 4) => error (substring "abc" 0 3) => "abc" substring-index Returns the zero-based index of the first occurrence of the specified substring in the argument string. If start is specified, the search begins at that index rather than at the beginning. Nil is returned if the substring does not occur in the searched range, or if the specified start index is past the end of the string. (substring-index "abcdefg" "cd") => 2 (substring-index "abcdabcd" "cd" 4) => 6 (substring-index "qrs" "cd") => nil string-append Returns a newly allocated string whose characters form the concatenation of the given strings. (string-append "a" "bc" "de") => "abcde" string->list String->list returns a newly allocated list of the characters that make up the String->given string. String->list and list->string are inverses so far as String->equal? is concerned. word-wrap Word-wrap converts a string into a list of strings, each being at most n characters long, where n is the first optional argument (75 by default). If a second boolean argument is given and is true, then carriage returns are converted to spaces before the string is word-wrapped. If the second optional argument missing or false, a carriage return is represented as a zero-length string in the result. Regardless of the optional arguments, the trailing white space is ignored and not represented in the resulting list. list->string List->string returns a newly allocated string formed from the characters in the list of args. String->list and list->string are inverses so far as equal? is concerned. string-copy Returns a newly allocated copy of the given string. string-fill! Stores arg2 in every element of the given arg1 and returns an unspecified value. See also make-string. vector? Returns #t if sexpr is a vector, otherwise returns #f. make-vector Returns a newly allocated vector of size elements. If a second argument is given, then each element is initialized to fillval. Otherwise the initial contents of each element is unspecified. vector Returns a newly allocated vector whose elements contain the given arguments. Analogous to list. (vector 'a 'b 'c) => #(a b c) vector-length Returns the number of elements in vector. (vector-length #(1 2 3)) => 3 vector-ref Vector-ref returns the kth element of vector. (vector-ref '#(1 1 2 3 5 8 13 21) 5) => 8 (vector-ref '#(1 1 2 3 5 8 13 21) (inexact->exact (round (* 2 (acos -1))))) => 13 vector-set! Vector-set! stores obj in element k of vector. The value returned by vector-set! is unspecified. (let ((vec (vector 0 '(2 2 2 2) "Anna"))) (vector-set! vec 1 '("Sue" "Sue")) vec) => #(0 ("Sue" "Sue") "Anna") (vector-set! '#(0 1 2) 1 "doe") => error ; constant vector vector->list Vector->list returns a newly allocated list of the objects contained in the elements of arg. See also list->vector. (vector->list '#(dah dah didah)) => (dah dah didah) list->vector List->vector returns a newly created vector initialized to the elements of the list arg. See also vector->list. (list->vector '(dididit dah)) => #(dididit dah) vector-fill! Stores arg2 in every element of arg1. The value returned by vector-fill! is unspecified. dictionary-keys Returns a list of the keys defined in the given dictionary. The keys appear in the list in no particular order, and that order may change with the addition or removal of a single key. In fact, there is no guarantee that successive calls to dictionary-keys on the same dictionary will produce the same ordering. See also make-dictionary, dictionary-ref, dictionary-set!, dictionary-unset!, dictionary-values. (let ((dict (make-dictionary 'eq?))) (dictionary-set! dict 'alpha "one") (dictionary-set! dict 'beta "two") (dictionary-keys dict)) => '(alpha beta) dictionary-values Returns a list of the values defined in the given dictionary. The values appear in the list in no particular order, and that order may change with the addition or removal of a single key-value pair. In fact, there is no guarantee that successive calls to dictionary-values on the same dictionary will produce the same ordering. See also make-dictionary, dictionary-ref, dictionary-set!, dictionary-unset!, dictionary-keys. (let ((dict (make-dictionary 'eq?))) (dictionary-set! dict 'alpha "one") (dictionary-set! dict 'beta "two") (dictionary-values dict)) => '("one" "two") dictionary-ref If the given dictionary has a value associated with the given key, that value is returned. If the key has no associated value, either the default (if supplied) or nil is returned. See also make-dictionary, dictionary-set!, dictionary-keys, dictionary-unset!. (define foo (make-dictionary 'eq?)) (dictionary-set! foo 10 "ten") (dictionary-ref foo 10) => "ten" (dictionary-ref foo 'x) => nil (dictionary-ref foo 'x 'nothing) => 'nothing dictionary-set! Inserts the given object into the dictionary associated with the given key. If the key previously had an associated value in the dictionary, that previous association is broken and the new association is established. Dictionary-set! returns #f if there was no previous association for that key, and returns #t if there was a previous association for that key. See also make-dictionary, dictionary-ref, dictionary-keys, dictionary-unset!. (define table (make-dictionary 'eq?)) (dictionary-set! table 'small '(helvetica 9 0)) => #f (dictionary-set! table 'small '(times 10 0.5)) => #t dictionary-unset! Removes any association that may have previously existed for the given key in the given dictionary. If an association existed for the key at the time of call to the dictionary-unset!, the procedure returns #t, otherwise it returns #f. The comparison used to match the key is either eq? or equal?, depending on how the dictionary was created (see make-dictionary). See also dictionary-ref, dictionary-set!, dictionary-keys. (define sys-table (make-dictionary 'eq?)) (dictionary-unset! sys-table 'foo) => #f (dictionary-set! sys-table 'foo 97) (dictionary-unset! sys-table 'foo) => #t make-dictionary Make-dictionary has two optional arguments. The first, currently required to be either 'eq? or 'equal, specifies the kind of comparison used on keys to search for and retrieve values from the dictionary. ('Equal?does not currently work for keys that are lists.) 'Eq? is the default. If the second argument is also given, it must be a positive integer and indicates the allocation size of the dictionary to create. The allocation size is the number of key->value associations that may be made before the dictionary must be automatically (and invisibly) enlarged. Since dictionary enlargement can involve a lot of copying and may significantly "overshoot" in size, you may gain some performance for large dictionaries if you give a reasonably close but conservative estimate in the second argument to make-dictionary. (define baz (make-dictionary)) => small dictionary using 'eq? for key comparison (dictionary-set! baz "black" '(0 0 0)) (define nob (make-dictionary 'equal?)) => small dictionary using 'equal? for key comparison (dictionary-set! nob "black" '(0 0 0)) (dictionary-ref bar "black") => nil (dictionary-ref nob "black") => '(0 0 0) dictionary->list Creates a list that is a projection of the given dictionary. The list is of the form ((k1 . v1) (k2 . v2) ...) where each k is a key from the dictionary and each v is the corresponding value at that key. Note that the result list is in a convenient form for using with assoc, assv and assq. select Select returns a new list containing references to the top-level members of the given list that cause the specified one-argument procedure to answer a true value (a true value in Alter is any value that is not eq? with #f). (select '("alpha" "beta" "gamma") (lambda (s) (string '("alpha" "beta") in-package This procedure currently does nothing except yield a nil return value. It is included for compatibility with emacs lisp modes. define Definitions are valid in some, but not all, contexts where expressions are allowed. They are valid only at the top level of a program and, in some implementations, at the beginning of a body. A definition should have one of the following forms: (define variable expression) (define (variable formals) body) Formals should be either a sequence of zero or more variables, or a sequence of one or more variables followed by a space-delimited period and another variable (as in a lambda expression). This form is equivalent to (define variable (lambda (formals) body)) (define (variable . formal) body) Formal should be a single variable. This form is equivalent to (define variable (lambda formal body)) At the top level of a program, a definition (define variable expression) has essentially the same effect as the assignment expression (set! variable expression) if variable is bound. If variable is not bound, however, then the definition will bind variable to a new location before performing the assignment, whereas it would be an error to perform a set! on an unbound unbound variable. (define add3 (lambda (x) (+ x 3))) (add3 3) => 6 (define (add2 x) (+ x 2)) (add3 3) => 5 (define (sum . args) (apply + args)) (sum 1 2 3 4 5) => 15 (define first car) (first '(1 2)) => 1 lambda Formals should be a formal arguments list as described below, and body should be a sequence of one or more expressions. A lambda expression evaluates to a procedure. The environment in effect when the lambda expression was evaluated is remembered as part of the procedure. When the procedure is later called with some actual arguments, the environment in which the lambda expression was evaluated will be extended by binding the variables in the formal argument list to fresh locations, the corresponding actual argument values will be stored in those locations, and the expressions in the body of the lambda expression will be evaluated sequentially in the extended environment. The result of the last expression in the body will be returned as the result of the procedure call. (lambda (x) (+ x x)) => a procedure ((lambda (x) (+ x x)) 4) => 8 (define reverse-subtract (lambda (x y) (- y x))) (reverse-subtract 7 10) => 3 (define add4 (let ((x 4)) (lambda (y) (+ x y)))) (add4 6) => 10 Formals should have one of the following forms: (variable . . .) The procedure takes a fixed number of arguments; when the procedure is called, the arguments will be stored in the bindings of the corresponding variables. variable The procedure takes any number of arguments; when the procedure is called, the sequence of actual arguments is converted into a newly allocated list, and the list is stored in the binding of the variable. variable1 . . . variablen-1 . variablen If a space-delimited period precedes the last variable, then the value stored in the binding of the last variable will be a newly allocated list of the actual arguments left over after all the other actual arguments have been matched up against the other formal arguments. It is an error for a variable to appear more than once in formals. ((lambda x x) 3 4 5 6) => (3 4 5 6) ((lambda (x y . z) z) 3 4 5 6) => (5 6) Each procedure created as the result of evaluating a lambda expression is tagged with a storage location, in order to make eqv? and eq? work on procedures. if Test, consequent, and alternate may be arbitrary expressions. An if expression is evaluated as follows: first, test is evaluated. If it yields a true value (any value which is not #f), then consequent is evaluated and its value is returned. Otherwise alternate is evaluated and its value is returned. If test yields a false value and no alternate is specified, then the result of the expression is unspecified. (if (> 3 2) 'yes 'no) => yes (if (> 2 3) 'yes 'no) => no (if (> 3 2) (- 3 2) (+ 3 2)) => 1 cond Each clause should be of the form (test expression . . .) where test is any expression. The last clause may be an ``else clause,'' which has the form (else expression1 expression2 . . .) A cond expression is evaluated by evaluating the test expressions of successive clauses in order until one of them evaluates to a true value. When a test evaluates to a true value, then the remaining expressions in its clause are evaluated in order, and the result of the last expression in the clause is returned as the result of the entire cond expression. If the selected clause contains only the test and no expressions, then the value of the test is returned as the result. If all tests evaluate to false values, and there is no else clause, then the result of the conditional expression is unspecified; if there is an else clause, then its expressions are evaluated, and the value of the last one is returned. (cond ((> 3 2) 'greater) ((< 3 2) 'less)) => greater (cond ((> 3 3) 'greater) ((< 3 3) 'less) (else 'equal)) => equal case Key may be any expression. Each clause should have the form ((datumi . . .) expression1 expression2 . . .) where each datum is an external representation of some object. All the datums must be distinct. The last clause may be an ``else clause,'' which has the form (else expression1 expression2 . . .) A case expression is evaluated as follows. Key is evaluated and its result is compared against each datum. If the result of evaluating key is equivalent (in the sense of eqv?) to a datum, then the expressions in the corresponding clause are evaluated from left to right and the result of the last expression in the clause is returned as the result of the case expression. If the result of evaluating key is different from every datum, then if there is an else clause its expressions are evaluated and the result of the last is the result of the case expression; otherwise the result of the case expression is unspecified. (case (* 2 3) ((2 3 5 7) 'prime) ((1 4 6 8 9) 'composite)) => composite (case (car '(c d)) ((a) 'a) ((b) 'b)) => unspecified (case (car '(c d)) ((a e i o u) 'vowel) ((w y) 'semivowel) (else 'consonant)) => consonant and The test expressions are evaluated from left to right, and the value of the first expression that evaluates to a false value is returned. Any remaining expressions are not evaluated. If all the expressions evaluate to true values, the value of the last expression is returned. If there are no expressions then #t is returned. (and (= 2 2) (> 2 1)) => #t (and (= 2 2) (< 2 1)) => #t (and 1 2 'c '(f g)) => #t (and) => #t or The test expressions are evaluated from left to right, and the value of the first expression that evaluates to a true value is returned. Any remaining expressions are not evaluated. If all expressions evaluate to false values, the value of the last expression is returned. If there are no expressions then #f is returned. (or (= 2 2) (> 2 1)) => #t (or (= 2 2) (< 2 1)) => #t (or #f #f #f) => #f (or (memq 'b '(a b c)) (/ 3 0)) => (b c) let Bindings should have the form ((variablei initi) . . .) where each initi is an expression, and body should be a sequence of one or more expressions. It is an error for a variable to appear more than once in the list of variables being bound. The inits are evaluated in the current environment (in some unspecified order), the variables are bound to fresh locations holding the results, the body is evaluated in the extended environment, and the value of the last expression of body is returned. Each binding of a variable has body as its region. (let ((x 2) (y 3)) (* x y)) => 6 (let ((x 2) (y 3)) (let ((x 7) (z (+ x y))) (* z x))) => 35 let* Bindings should have the form ((variablei initi) . . .) and body should be a sequence of one or more expressions. Let* is similar to let, but the bindings are performed sequentially from left to right, and the region of a binding indicated by (variable init) is that part of the let* expression to the right of the binding. Thus the second binding is done in an environment in which the first binding is visible, and so on. (let ((x 2) (y 3)) (let* ((x 7) (z (+ x y))) (* z x))) => 70 letrec Bindings should have the form ((variablei initi) . . .) and body should be a sequence of one or more expressions. It is an error for a variable to appear more than once in the list of variables being bound. The variables are bound to fresh locations holding undefined values, the inits are evaluated in the resulting environment (in some unspecified order), each variable is assigned to the result of the corresponding init, the body is evaluated in the resulting environment, and the value of the last expression in body is returned. Each binding of a variable has the entire letrec expression as its region, making it possible to define mutually recursive procedures. (letrec ((even? (lambda (n) (if (zero? n) #t (odd? (- n 1))))) (odd? (lambda (n) (if (zero? n) #f (even? (- n 1)))))) (even? 88)) => #t One restriction on letrec is very important: it must be possible to evaluate each init without assigning or referring to the value of any variable. If this restriction is violated, then it is an error. The restriction is necessary because Scheme passes arguments by value rather than by name. In the most common uses of letrec, all the inits are lambda expressions and the restriction is satisfied automatically. begin The expression are evaluated sequentially from left to right, and the value of the last expression is returned. This expression type is used to sequence side effects such as input and output. (define x 0) (begin (set! x 5) (+ x 1)) => 6 (begin (display "4 plus 1 equals ") (display (+ 4 1))) => unspecified . . . and prints 4 plus 1 equals 5 do Detailed syntax is as follows: (do ((variable1 init1 step1) . . .) (test expression . . .) command . . .) Do is an iteration construct. It specifies a set of variables to be bound, how they are to be initialized at the start, and how they are to be updated on each iteration. When a termination condition is met, the loop exits with a specified result value. Do expressions are evaluated as follows: The init expressions are evaluated (in some unspecified order), the variables are bound to fresh locations, the results of the init expressions are stored in the bindings of the variables, and then the iteration phase begins. Each iteration begins by evaluating test; if the result is false, then the command expressions are evaluated in order for effect, the step expressions are evaluated in some unspecified order, the variables are bound to fresh locations, the results of the steps are stored in the bindings of the variables, and the next iteration begins. If test evaluates to a true value, then the expressions are evaluated from left to right and the value of the last expression is returned as the value of the do expression. If no expressions are present, then the value of the do expression is unspecified. The region of the binding of a variable consists of the entire do expression except for the inits. It is an error for a variable to appear more than once in the list of do variables. A step may be omitted, in which case the effect is the same as if (variable init variable) had been written instead of (variable init). (do ((vec (make-vector 5)) (i 0 (+ i 1))) ((= i 5) vec) (vector-set! vec i i)) => #(0 1 2 3 4) (let ((x '(1 3 5 7 9))) (do ((x x (cdr x)) (sum 0 (+ sum (car x)))) ((null? x) sum))) => 25 initialize Performs any necessary initialization on the object and returns the initialized object. Initialize is called automatically by the operation make. copy Returns a copy of the argument. Most things in Alter are constants and so copy returns the argument itself. Copying strings returns a string of equal length to the argument string such that char=? is true for each corresponding character of the argument and the result (equivalent to string-copy). Copying lists returns a list of equal length to the argument list such that eq? returns true for each corresponding element of the argument and the result. Copying vectors returns a vector of equal length to the argument vector such that eq? returns true for each corresponding element of the argument and the result. Copying dictionaries returns a dictionary of equal size to the argument dictionary such that eq? returns true for each corresponding key of the argument and the result and eq? returns true for each corresponding value of the argument and the result. Copying grapethings is dependent on how the particular subclass implements copying itself. Copying instances of user-defined-types returns an object whose instance variables are set to a copy of the object that the argument's instance variable was set to. copy-without Returns a copy of the list with all top-level references to object removed (using eq? test). (copy-without '(a b c) 'b) => (a c) (copy-without '(a b c b) 'b) => (a c) (copy-without '(b) 'b) => () (copy-without '(a b . c) 'b) => (a . c) (copy-without '(b . c) 'b) => (nil . c) (copy-without '(nil nil nil . c) 'nil) => (nil . c) (copy-without '("a" "b" "c") "b") => ("a" "b" "c") (copy-without '(a (b c)) 'b) => (a (b c)) remove-from-list! Returns the argument list with all top-level references to object removed (using eq? test). Note that the return value will not be the same as the list passed in if the first element is eq? to object. This operation is destructive to the argument list, so any references to list may also be affected. The structure and values of the resulting list are the same as defined for copy-without. (define foo '(a b c)) (remove-from-list! foo 'b) => (a c) foo => (a c) (define foo '(a b a c)) (remove-from-list! foo 'a) => (b c) foo => (a b c) (remove-from-list! '(a b c b) 'b) => (a c) (remove-from-list! '(b) 'b) => () (remove-from-list! '(a b . c) 'b) => (a . c) (remove-from-list! '(b . c) 'b) => (nil . c) (remove-from-list! '(nil nil nil . c) 'nil) => (nil . c) (remove-from-list! '("a" "b" "c") "b") => ("a" "b" "c") (remove-from-list! '(a (b c)) 'b) => (a (b c)) quote Returns the argument. The argument may be any external representation of an Alter object. This notation is used to include literal constants in Alter code. (quote a) => a (quote #(a b c)) => #(a b c) (quote (+ 1 2)) => (+ 1 2) (quote object) may be abbreviated as 'object. The two notations are equivalent in all respects. 'a => a '#(a b c) => #(a b c) '() => () '(+ 1 2) => (+ 1 2) '(quote a) => (quote a) ''a => (quote a) Numerical constants, string constants, character constants, and boolean constants evaluate "to themselves"; they need not be quoted. '"abc" => "abc" "abc" => "abc" '145932 => 145932 145932 => 145932 '#t => #t #t => #t It is an error to alter a constant (i.e the value of a literal expression) using a mutation procedure like set-car! or string-set!. set! Expression is evaluated, and the resulting value is stored in the location to which variable is bound. Variable must be bound either in some region enclosing the set! expression or at top level. The result of the set! expression is unspecified. (define x 2) (+ x 1) => 3 (set! x 4) => unspecified (+ x 1) => 5 procedure? Returns #t if sexpr is a procedure, otherwise returns #f. (procedure? car) => #t (procedure? 'car) => #f (procedure? (lambda (x) (* x x))) => #t (procedure? '(lambda (x) (* x x))) => #f (call-with-current-continuation procedure?) => #t operation? Returns true if the given object represents an operation, as defined by make or find-operation; returns false otherwise. (operation? new-in) => #t (operation? car) => #f thunk? Returns #t if the object is a procedure or operation, otherwise it returns #f. (thunk? car) => #t (thunk? length) => #t (procedure? length) => #f (operation? length) => #t apply Calls proc with the elements of list as the actual arguments. (apply + (list 3 4)) => 7 (define compose (lambda (f g) (lambda args (f (apply g args))))) ((compose sqrt *) 12 75) => 30 eval Evaluates the expression (a second time) and returns the result of that evaluation. (eval 5) => 5 (eval 'eq?) => a procedure (eval (list '+ 2 7)) => 9 map Map applies proc element-wise to the elements of the lists and returns a list of the results, in order from left to right. The dynamic order in which proc is applied to the elements of the lists is unspecified. (map cadr '((a b) (d e) (g h))) => (b e h) (map (lambda (n) (expt n n)) '(1 2 3 4 5)) => (1 4 27 256 3125) (map + '(1 2 3) '(4 5 6)) => (5 7 9) (let ((count 0)) (map (lambda (ignored) (set! count (+ count 1)) count) '(a b c))) => unspecified for-each The arguments to for-each are like the arguments to map, but for-each calls proc for its side effects rather than for its values. Unlike map, for-each is guaranteed to call proc on the elements of the lists in order from the first element to the last, and the value returned by for-each is unspecified. (let ((v (make-vector 5))) (for-each (lambda (i) (vector-set! v i (* i i))) '(0 1 2 3 4)) v) => #(0 1 4 9 16) force Forces the value of arg1 (see delay). If no value has been computed for the promise, then a value is computed and returned. The value of the promise is cached (or ``memorized'') so that if it is forced a second time, the previously computed value is returned. (force (delay (+ 1 2))) => 3 (let ((p (delay (+ 1 2)))) (list (force p) (force p))) => (3 3) (define a-stream (letrec ((next (lambda (n) (cons n (delay (next (+ n 1))))))) (next 0))) (define head car) (define tail (lambda (stream) (force (cdr stream)))) (head (tail (tail a-stream))) => 2 Force and delay are mainly intended for programs written in functional style. The following examples should not be considered to illustrate good programming style, but they illustrate the property that only one value is computed for a promise, no matter how many times it is forced. (define count 0) (define p (delay (begin (set! count (+ count 1)) (if (> count x) count (force p))))) (define x 5) p => promise (force p) => 6 p => promise, still (begin (set! x 10) (force p)) => 6 Here is a possible implementation of delay and force. Promises are implemented here as procedures of no arguments, and force simply calls its argument: (define force (lambda (object) (object))) We define the expression (delay expression) to have the same meaning as the procedure call (make-promise (lambda () expression)), where make-promise is defined as follows: (define make-promise (lambda (proc) (let ((result-ready? #f) (result #f)) (lambda () (if result-ready? result (let ((x (proc))) (if result-ready? result (begin (set! result-ready? #t) (set! result x) result)))))))) sleep Causes the DOME process to go inactive for the specified number of milliseconds. This is useful for animation and other related purposes. shell Synchronously executes the command with the string args and returns its exit status as an integer. Zero usually means success; non-zero means failure. call-with-current-continuation The procedure call-with-current-continuation packages up the current continuation (see the rationale below) as an ``escape procedure'' and passes it as an argument to arg. The escape procedure is a Scheme procedure of one argument that, if it is later passed a value, will ignore whatever continuation is in effect at that later time and will give the value instead to the continuation that was in effect when the escape procedure was created. The escape procedure that is passed to arg has unlimited extent just like any other procedure in Scheme. It may be stored in variables or data structures and may be called as many times as desired. The following examples show only the most common uses of call-with-current-continuation. If all real programs were as simple as these examples, there would be no need for a procedure with the power of call-with-current-continuation. (call-with-current-continuation (lambda (exit) (for-each (lambda (x) (if (negative? x) (exit x))) '(54 0 37 -3 245 19)) #t)) => -3 (define list-length (lambda (obj) (call-with-current-continuation (lambda (return) (letrec ((r (lambda (obj) (cond ((null? obj) 0) ((pair? obj) (+ (r (cdr obj)) 1)) (else (return #f)))))) (r obj)))))) (list-length '(1 2 3 4)) => 4 (list-length '(a b . c)) => #f call-with-input-file This procedures call the given thunk (procedure or operation) with one argument: the port obtained by opening the named file for input. If the file cannot be opened, an error is signalled. If the procedure returns, then the port is closed automatically and the value yielded by the procedure is returned. If the procedure does not return, then the port will not be closed automatically unless it is possible to prove that the port will never again be used for a read or write operation. call-with-output-file This procedure calls the given thunk (procedure or operation) with one argument: the port obtained by opening the named file for output. If the file cannot be opened, an error is signalled. If the procedure returns, then the port is closed automatically and the value yielded by the procedure is returned. If the procedure does not return, then the port will not be closed automatically unless it is possible to prove that the port will never again be used for a read or write operation. call/cc This is an alias for call-with-current-continuation. call-with-current-continuation Proc must be a procedure of one argument. The procedure call-with-current-continuation packages up the current continuation (see the rationale below) as an ``escape procedure'' and passes it as an argument to proc. The escape procedure is a Scheme procedure of one argument that, if it is later passed a value, will ignore whatever continuation is in effect at that later time and will give the value instead to the continuation that was in effect when the escape procedure was created. In standard Scheme, the escape procedure that is passed to proc has unlimited extent just like any other procedure in Scheme. But this is not the case in Alter, where the escape procedure's extent is limited to the duration of the activation of the call-with-current-continuation that defined it. The escape procedure may be stored in variables or data structures. The following examples show only the most common uses of call-with-current-continuation. If all real programs were as simple as these examples, there would be no need for a procedure with the power of call-with-current-continuation. (call-with-current-continuation (lambda (exit) (for-each (lambda (x) (if (negative? x) (exit x))) '(54 0 37 -3 245 19)) #\t)) => -3 (define list-length (lambda (obj) (call-with-current-continuation (lambda (return) (letrec ((r (lambda (obj) (cond ((null? obj) 0) ((pair? obj) (+ (r (cdr obj)) 1)) (else (return #f)))))) (r obj)))))) (list-length '(1 2 3 4)) => 4 (list-length '(a b . c)) => #f A common use of call-with-current-continuation is for structured, non-local exits from loops or procedure bodies, but in fact call-with-current-continuation is extremely useful for implementing a wide variety of advanced control structures. Whenever a Scheme expression is evaluated there is a continuation wanting the result of the expression. The continuation represents an entire (default) future for the computation. If the expression is evaluated at top level, for example, then the continuation might take the result, print it on the screen, prompt for the next input, evaluate it, and so on forever. Most of the time the continuation includes actions specified by user code, as in a continuation that will take the result, multiply it by the value stored in a local variable, add seven, and give the answer to the top level continuation to be printed. Normally these ubiquitous continuations are hidden behind the scenes and programmers don't think much about them. On rare occasions, however, a programmer may need to deal with continuations explicitly. Call-with-current-continuation allows Scheme programmers to do that by creating a procedure that acts just like the current continuation. Most programming languages incorporate one or more special-purpose escape constructs with names like 'exit', 'return', or even 'goto'. In 1965, however, Peter Landin invented a general purpose escape operator called the J-operator. John Reynolds described a simpler but equally powerful construct in 1972. The "catch" special form described by Sussman and Steele in the 1975 report on Scheme is exactly the same as Reynolds's construct, though its name came from a less general construct in MacLisp. Several Scheme implementors noticed that the full power of the "catch" construct could be provided by a procedure instead of by a special syntactic construct, and the name call-with-current-continuation was coined in 1982. This name is descriptive, but opinions differ on the merits of such a long name, and some people use the name call/cc instead. port? Returns #t if the given object is either an input port or an output port. Otherwise returns #f. See open-input-file, open-output-file and terminal. input-port? Returns #t if the given port is an input port, otherwise returns #f. See open-input-file. output-port? Returns #t if the given port is an output port, otherwise returns #f. See open-output-file and terminal. current-input-port Returns the current default input port. Alter does not always have a default input port, so the return value may be nil. See with-input-from-file. current-output-port Returns the current default input or output port. See with-output-to-file. with-input-from-file The file is opened for input, an input port connected to it is made the default value returned by current-input-port, and the thunk (procedure or operation) is called with no arguments. When the thunk returns, the port is closed and the previous default is restored. With-input-from-file returns the value yielded by thunk. If an escape procedure is used to escape from the continuation of this procedure, the port is closed. with-output-to-file The file is opened for output, an output port connected to it is made the default value returned by current-output-port, and the thunk (procedure or operation) is called with no arguments. When the thunk returns, the port is closed and the previous default is restored. With-output-to-file returns the value yielded by thunk. If an escape procedure is used to escape from the continuation of these procedures, the port is closed. open-input-file Takes a string or filename representing an existing file and returns an input port capable of delivering characters from the file. If the file cannot be opened, an error is signalled. open-output-file Takes a string or filename representing an output file to be created and returns an output port capable of writing characters to a new file by that name. If the file cannot be opened, an error is signalled. If a file with the given name already exists, the effect is unspecified. If the string "" is passed as the argument then a transcript window is opened and its port is returned. terminal Unix only. Starts the command specified by the given string, opens a VT100 terminal window whose stdin and stdout are connected to the new process, and returns an output port that can be used to send characters to the process' stdin. Additional arguments to terminal must be strings, and are appended to the command line used to start the process. close-input-port Closes the file associated with port, rendering the port incapable of accepting characters. This routine has no effect if the port has already been closed. The value returned is unspecified. close-output-port Closes the file associated with port, rendering the port incapable of generating characters. This routine has no effect if the port has already been closed. The value returned is unspecified. construct Returns a new filename instance whose head is the given filename, and whose tail consists of the given string. The precise behavior of this operation is host-specific. dome-home Returns a filename instance that represents the directory containing DOME's library and support files. The behavior of this procedure is host- and installation-specific. On Unix and Windows NT systems, the pathname comes from the environment variable "DOMEHOME"; if it is not set then the start up directory is used. On DOS machines, the start up directory is used. On Macintosh systems, Alter uses the pathname of the directory containing the DOME application. user-home Returns a filename instance that represents the home directory of the user. The behavior of this procedure is host- and installation-specific. Note: Macintosh and Windows hosts do not ordinarily support the concept of user home directories. For Macintosh installations, (user-home) is the same as (dome-home). In Windows and Unix installations, if the HOME environment variable is set, that is used to form the filename, otherwise "C:\" is used for Windows, and "/" is used for Unix. current-directory Returns a filename instance that represents the directory in which DOME was started. The behavior of this procedure is host- and installation-specific. For Macintosh installations, (current-directory) is the same as (dome-home). delete Deletes the file represented by the given filename. exists Returns #t if the specified file exists, otherwise returns #f. head Returns a string representing the given filename with the last component removed. If the filename represents a file, the directory path is returned. If the filename represents a directory, the parent directory path is returned. tail Returns a string representing the given filename with all but the last component removed. as-backup Returns a string that is derived from the given filename and can be used as a backup for that filename. The behavior of this operation is host-specific. directory? Returns #t if the filename represents a directory on the host system. Returns #f otherwise. writable? Returns #t if the filename represents a file than can be opened for writing. Otherwise returns #f. The file must exist, or Alter will raise an error. as-string Returns a string representing filename. make-directory Causes the host to create the directory represented by filename. The behavior of this function is host-specific. Everything but the last component of filename must already exist before make-directory is called; it is an error otherwise. contents Returns the contents of the specified filename. If the file does not exist, Alter will raise an error. temporary-filename Returns a filename that can be opened for writing to save temporary data, such as a file to print. The composition of the filename may be host-specific. move-to Renames filename to destination (another filename). Destination may be a completely different pathname, but the behavior of move-to is host-specific if filename and destination are on different devices. It is an error if destination cannot be opened for writing or filename cannot be opened for reading. copy-to Copies filename to destination (another filename). Destination may be a completely different pathname. It is an error if destination cannot be opened for writing or filename cannot be opened for reading. dates Returns a dictionary with the file's access dates. resolve Returns the full path of a file if it exists along the dome-load-path, otherwise returns the filename unaltered. load-path Returns the current path used by dome to resolve filenames. This path is the concatenation of any user specified path (the value of *dome-load-path*) with the default load path. read Read converts external representations of Scheme objects into the objects themselves. That is, it is a parser for the nonterminal datum. Read returns the next object parsable from the given input arg, updating arg to point to the first character past the end of the external representation of the object. If an end of file is encountered in the input before any characters are found that can begin an object, then an end of file object is returned. The port argument may be omitted, in which case it defaults to the value returned by current-input-port. It is an error to read from a closed port. read-char Returns the next character available from the input port, updating the port to point to the following character. If no more characters are available, an end of file object is returned. Port may be omitted, in which case it defaults to the value returned by current-input-port. peek-char Returns the next character available from the input port, without updating the port to point to the following character. If no more characters are available, an end of file object is returned. Port may be omitted, in which case it defaults to the value returned by current-input-port. The value returned by a call to peek-char is the same as the value that would have been returned by a call to read-char with the same port. The only difference is that the very next call to read-char or peek-char on that port will return the value returned by the preceding call to peek-char. In particular, a call to peek-char on an interactive port will hang waiting for input whenever a call to read-char would have hung. eof-object? Returns #t if arg is an end of file object, otherwise returns #f. The precise set of end of file objects will vary among implementations, but in any case no end of file object will ever be an object that can be read in using read. char-ready? Returns #t if a character is ready on the input port and returns #f otherwise. If char-ready returns #t then the next read-char operation on the given port is guaranteed not to hang. If the port is at end of file then char-ready? returns #t. Port may be omitted, in which case it defaults to the value returned by current-input-port. write Writes a written representation of sexpr to the given port. Strings that appear in the written representation are enclosed in doublequotes, and within those strings backslash and doublequote characters are escaped by backslashes. Write returns an unspecified value. The port argument may be omitted, in which case it defaults to the value returned by current-output-port. display Writes a representation of sexpr to the given port. Strings that appear in the written representation are not enclosed in doublequotes, and no characters are escaped within those strings. Character objects appear in the representation as if written by write-char instead of by write. Display returns an unspecified value. The port argument may be omitted, in which case it defaults to the value returned by current-output-port. newline Writes an end of line to port. Exactly how this is done differs from one operating system to another. Returns an unspecified value. The port argument may be omitted, in which case it defaults to the value returned by current-output-port. message-to-user Writes the specified string to the DOME message pane in the DOME Launcher window, followed by a newline. write-char Writes the character (not an external representation of the character) to the given port and returns an unspecified value. The port argument may be omitted, in which case it defaults to the value returned by current-output-port. load The load procedure reads expressions and definitions from the file and evaluates them sequentially. It is unspecified whether the results of the expressions are printed. The load procedure does not affect the values returned by current-input-port and current-output-port. Load returns an unspecified value. The argument may be either a string or a filename instance (see string->filename). If the file name is a relative pathname, DOME searches a sequence of directories. The sequence is determined by the contents of the global symbol *dome-load-path* plus the default directories obtained through the expression (construct (construct (construct dome-home "tools") "*") "lib") The directories given in *dome-load-path*, if any, are searched first in order, followed by the default directories. You can set *dome-load-path* in your DOME initialization file (see the DOME User's Manual). transcript-on The effect of transcript-on is to open the named file for output, and to cause a transcript of subsequent interaction between the user and the Scheme system to be written to the file. The transcript is ended by a call to transcript-off, which closes the transcript file. Only one transcript may be in progress at any time, though some implementations may relax this restriction. The values returned by these procedures are unspecified. error This procedure stops execution and displays the Alter Environment Browser (Activation Stack) with the argument as the text in the message box. date-today Returns a list containing a representation of the current system date. The list is interpreted as follows: (year day-of-year). time-now Returns a list containing a representation of the current system time. The list is interpreted as follows: (hours minutes seconds). choices This function may go away in the future. decision-diagram This function may go away in the future. decisiondiagram->grapething This function may go away in the future. edges This function may go away in the future. id This function may go away in the future. index This function may go away in the future. paths This function may go away in the future. reduced-diagram! This function may go away in the future. root This function may go away in the future. add-child Checks to see if aGraphModel is a subdiagram of aGraphObject. If it is NOT a subdiagram it adds aGraphModel to aGraphObject's subdiagrams and returns aGraphModel. Otherwise returns nil. addbehavioroutput-after Add the second argument (a behavior output reference) to the receiver's collection of behavior outputs. If the third argument is nil then add it as the last output, otherwise add it after the third argument. addprocedure-after Add the second argument (an operational procedure) to the receiver's collection of procedures. If the third argument is nil then add it as the last procedure, otherwise add it after the third argument. addscenarioinput-after Add the second argument (a scenario input reference) to the receiver's collection of scenario inputs. If the third argument is nil then add it as the last input, otherwise add it after the third argument. do-over-model Traverse the grapething's model and apply the thunk to each object contained in the model. read-through-char Return a string from the current position of the port to the first occurrence of char inclusive. If char is not encountered then return the entire string from port. get-property-definition Return the property definition for the named property. get-property-definitions Return all (or those that have a category of categoryname) of the property definitions for the specified object. remove Deletes the specified grapething from its container and removes all other references to it. archetype? Is the object an archetype? default-child-type Returns the default type of graphmodel created when a new subdiagram is added. implementations If aGraphObject has an archetype then this returns the archetypes's implementations. Otherwise it returns aGraphObject's subdiagrams. remove-child Checks to see if aGraphModel is a subdiagram of aGraphObject. If it is a subdiagram it removes aGraphModel from aGraphObject's subdiagrams and returns aGraphModel. Otherwise returns nil. text-line-height Return the space between lines. open-input-string Opens an input port on the string argument. provide Each module has a unique name (a string). The provide and require functions accept either a string or a symbol as the module-name argument. If a symbol is provided, its print-name is used as the module name. The provide procedure adds a new module name to the list of modules, thereby indicating that the module in question has been loaded. require Each module has a unique name (a string). The provide and require functions accept either a string or a symbol as the module-name argument. If a symbol is provided, its print-name is used as the module name. The require function tests whether a module is already present; if the module is not present, require proceeds to load the appropriate file or set of files. The pathname argument, if present, is a single filename that is to be loaded. If the pathname argument is not provided, the system will attempt to determine which files to load by searching along the DOME load-path as follows: - first, it will look for a file named module-name, - next, it will look for a file named module-name.alt, - last, it will look for a file named module-name.lib. Alter also records the modified timestamp of a module's file when it loads it. If the module has already been loaded, Alter will check the current timestamp of the file. If it is later than the stored timestamp then Alter will re-load the module. open-output-string Opens an output port on the string argument. substitute Return a copy of the string such that all occurrences of substring are replaced with the replacement string. trim Returns a copy of the string with all white space removed from its end. White space characters include space, car, the result of evaluating `