                !!!!!! DON'T TRIM !!!!!!
*try
[1m(try <tried-expr>
   (<symbol> <expr> <expr> ...)
   ...
   [(else <expr> <expr> ...)])
[m
Exceptions can be ``caught'' with the [1mtry[m special form when a
[4mhandler[m for that exception has been installed.
If no exception was raised during the evaluation of
[4m<tried-expr>[m, its value is returned as the result of the
[1mtry[m special form.
Otherwise, the exception (any symbol) is search in the a-list that follows
[4m<tried-expr>[m. If it is found (or a default handler following
``else'' is installed), the ``handler'' (a sequence of expressions)
following it is evaluated. If the value of this sequence is not a
procedure, it is returned as the result of the [1mtry[m special
form. Otherwise, the procedure -- that must be a unary procedure -- is
called with the value sent by the exception, the value it returns
becomes the result of the special form.

See [1mraise[m for the descriptions of the errors that are
sent by the evaluator.[m

Other keywords, see : [1mkeyword?[m 
-----
*define
A Scheme program consists of a sequence of expressions and definitions.
Programs are typically stored in files or entered interactively to a
running Scheme system.

Definitions occurring at the top level of a program can be interpreted
declaratively.  They cause bindings to be created in the top level
environment.  Expressions occurring at the top level of a program are
interpreted imperatively; they are executed in order when the program is
invoked or loaded, and typically perform some kind of initialization.

Definitions are valid in some, but not all, contexts where expressions
are allowed.  They are valid only at the top level of a [4m<program>[m
and at the beginning of a [4m<body>[m.

A definition should have one of the following forms:

1) [1m(define <variable> <expression>)[m

2) [1m(define (<variable> <formals>) <body>)[m
[4m<Formals>[m 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). It is equivalent to
[1m(define <variable> (lambda (<formals>) <body>)).
[m
3) [1m(define (<variable> . <formal>) <body>)[m
[4m<Formal>[m should be a single variable.  This form is equivalent to
[1m(define <variable> (lambda <formal> <body>)).
[m
4) [1m(begin <definition 1> ...)[m
This form is equivalent to the set of definitions that form the body
of the [1mbegin[m.

At the top level of a program, a definition
[1m(define <variable> <expression>)[m has essentially the same
effect as the assignment expression [1m(set! <variable> <expression>)[m
if [4m<variable>[m is bound.  If [4m<variable>[m is not bound, however, then the
definition will bind [4m<variable>[m to a new location before performing
the assignment, whereas it would be an error to perform a [1mset![m
on an unbound variable.

[1m(define add3
  (lambda (x) (+ x 3)))
(add3 3)                    =>  6
(define first car)
(first '(1 2))              =>  1
[m

SWiT implementation of Scheme uses an initial environment in which all
possible variables are bound to locations, most of which contain
undefined values. So, top-level definitions are equivalent to
assignments.

[4mInternal definitions[m:

SWiT implementation of Scheme permit definitions to occur at the
beginning of a [4m<body>[m (that is, the body of a [1mlambda[m, [1mlet[m,
[1mlet*[m, [1mletrec[m, or [1mdefine[m expression).
Such definitions are known as [4minternal definitions[m as opposed to the
[4mtop-level definitions[m described above.

The variable defined by an internal definition is local to the
[4m<body>[m.  That is, [4m<variable>[m is bound rather than assigned,
and the region of the binding is the entire [4m<body>[m.  For example,
[1m
(let ((x 5))
  (define foo (lambda (y) (bar x y)))
  (define bar (lambda (a b) (+ (* a b) a)))
  (foo (+ x 3)))            =>  45
[m
A [4m<body>[m containing internal definitions can always be converted
into a completely equivalent [1mletrec[m expression.  For example,
the [1mlet[m expression in the above example is equivalent to
[1m
(let ((x 5))
  (letrec ((foo (lambda (y) (bar x y)))
           (bar (lambda (a b) (+ (* a b) a))))
    (foo (+ x 3))))
[m

Just as for the equivalent [1mletrec[m expression, it must be
possible to evaluate each [4m<expression>[m of every internal definition in
a [4m<body>[m without assigning or referring to the value of any [4m<variable>[m
being defined.[m

Other keywords, see : [1mkeyword?[m 
-----
*defmacro
*define-syntax
[1m(defmacro <variable> <formals> <expression>)[m

[4m<formals>[m follows the usual syntax (as for a lambda expression).

Example:[1m
> (defmacro while (test . body) `(do () ((not ,test)) ,@body))
  => while[m

Alternatively, [1mdefine-syntax[m can be used, e.g. :
[1m
(define-syntax while
  (syntax-rules ()
    ((while test expr ...)
     (do () ((not test)) expr ...))))[m

Other keywords, see : [1mkeyword?[m 
-----
*defclass
[1m(defclass (<ClassName> . <InstanceVariableList>) [<SuperClassName>]
     <Method-or-ClassVar> ...)[m

Where:
  [4m<InstanceVariableList>[m must be a proper list of variables
  [4m<SuperClassName>[m is optional and default to [4m<obj>[m the class of all classes	
  [4m <Method-or-ClassVar>[m == [4m<Method>[m or [4m<ClassVar>[m
     with:
      [4m<Method>[m == [1m(<method name> <formals> <expr> <expr> ...)[m
      [4m<ClassVar>[m == [1m(<variable> <expr>)[m

The `class' created by [1mdefclass[m is a function that creates its instances.

The object system has :
  -- simple inheritance,
  -- `self' and `super',
 but no :
  -- abstract classes,
  -- protection (everything is mutable and public),
  -- class browser.

Moreover, methods must be defined when defining the class and new
methods cannot be added later. 

An instance is implemented as an environment which binds: 
the class name, the methods, the class variables, and 
the instances variables.

Examples:
[1m
;;; Defining a class `<c>' which superclass is not explicitly 
;;; given (and will be the class <obj> by default) :
> (defclass (<c> u v) (a 0) (result (x) (* x (self 'u)))) => <c>

;;; the instances variables `u' and `v' can be initialised 
;;; in any order. They can also be initialised later :
> (define c (<c> 'v -1 'u 5)) => c  

;;; calling the method `result' :
> (c 'result 4) => 20

;;; `class:' is a class variable always bound to
;;; the classname. You must not define a class
;;; variable of this name :
> (c 'class:) => <c> 

;;; returns the value of the class variable `a' :
> (c 'a) => 0 

;;; assigns the instance variable `v' to a new value :
> (set! (c 'v) 8) => 8 

;;; this method belongs to all classes and gives minimum 
;;; (yet useful) information about the instance :
> (c 'info) 
Class: <c>
Inheritance: <obj>
Class variables:
  a = 0
Methods: result print info
Instance variables:
  u = 5
  v = 8
=> #t

;;; The default printing, can be overridden by redefining 
;;; the <obj> method `print', see the file `formals.swt' 
;;; for an example :
> c => #<<c>> [m

Hash tables are implemented with the object system 
(the file `hash.swt' is loaded when swit starts) :
[1m
> (define ht (<hash-table> 'size 5))
;;; then add new members with :
> (ht 'put! "Dupont" 'France) => (("Dupont" france))
> (ht 'put! "Smith" 'England) => (("Smith" england))
;;; A collision :
> (ht 'put! "Wang" 'China) => (("Wang" china) ("Dupont" france))
;;; An other collision (bad luck) :
> (ht 'put! "Szabo" 'Hungary) 
=> (("Szabo" hungary) ("Wang" china) ("Dupont" france))

;;; Then retreive with :
(ht 'get "Wang") => (china)
;;; A list has been returned (with 1 element) 
;;; because any number of arguments (possibly none) 
;;; can be passed to the method `put!'. [m

[4mImportant[m: the size of the hash-table must be changed with the
method `resize' and by an assignement to the variable `size'.

See also the files `objects-test.swt', `objects-examples.swt' [m 
-----
*let
[1m(let <bindings> <body>)
(let <variable> <bindings> <body>)
[m
[4m<bindings>[m should have the form [1m((<variable 1> <init 1>) ...)[m,
where each [4m<init>[m is an expression, and [4m<body>[m should be a sequence of
one or more expressions. It is an error for a [4m<variable>[m to appear
more than once in the list of variables being bound.

In the first form, the [4m<init>[ms are evaluated in turn in the current
environment, the [4m<variable>[ms are bound to fresh locations holding the
results, the [4m<body>[m is evaluated in the extended environment, and the
value of the last expression of [4m<body>[m is returned. Each binding of a
[4m<variable>[m has [4m<body>[m as its region.
[1m
(let ((x 2) (y 3))
  (* x y))                  =>  6

(let ((x 2) (y 3))
  (let ((x 7)
        (z (+ x y)))
    (* z x)))               =>  35[m

The second form is variant on the syntax of [1mlet[m called "named
[1mlet[m" which provides a more general looping construct than
[1mdo[m, and may also be used to express recursions.

Named [1mlet[m has the same syntax and semantics as ordinary
[1mlet[m except that [4m<variable>[m is bound within [4m<body>[m to a
procedure whose formal arguments are the bound variables and whose
body is [4m<body>[m.  Thus the execution of [4m<body>[m may be repeated by
invoking the procedure named by [4m<variable>[m.
[1m
(let loop ((numbers '(3 -2 1 6 -5))
           (nonneg '())
           (neg '()))
  (cond ((null? numbers) (list nonneg neg))
        ((>= (car numbers) 0)
         (loop (cdr numbers)
               (cons (car numbers) nonneg)
               neg))
        ((< (car numbers) 0)
         (loop (cdr numbers)
               nonneg
               (cons (car numbers) neg)))))
                            =>  ((6 1 3) (-5 -2))[m 

Other keywords, see : [1mkeyword?[m 
-----
*let*
[1m(let* <bindings> <body>)
[m
[4m<bindings>[m should have the form [1m((<variable 1> <init 1>) ...)[m,
and [4m<body>[m should be a sequence of one or more expressions.

[1mLet*[m is similar to [1mlet[m, but the bindings are performed
sequentially from left to right, and the region of a binding indicated
by [1m(<variable> <init>)[m is that part of the [1mlet*[m
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.
[1m
(let ((x 2) (y 3))
  (let* ((x 7)
         (z (+ x y)))
    (* z x)))               =>  70[m 

Other keywords, see : [1mkeyword?[m 
-----
*letrec
[1m(letrec <bindings> <body>)
[m
[4m<bindings>[m should have the form [1m((<variable 1> <init 1>) ...)[m,
and [4m<body>[m should be a sequence of one or more expressions. It
is an error for a [4m<variable>[m to appear more than once in the
list of variables being bound.

The [4m<variable>[ms are bound to fresh locations holding undefined values,
the [4m<init>[ms are evaluated in turn in the resulting environment, each
[4m<variable>[m is assigned to the result of the corresponding [4m<init>[m, the
[4m<body>[m is evaluated in the resulting environment, and the value of the
last expression in [4m<body>[m is returned.  Each binding of a [4m<variable>[m
has the entire [1mletrec[m expression as its region , making it
possible to define mutually recursive procedures.
[1m
(letrec ((even?
          (lambda (n)
            (if (zero? n)
                #t
                (odd? (- n 1)))))
         (odd?
          (lambda (n)
            (if (zero? n)
                #f
                (even? (- n 1))))))
  (even? 88))
                            =>  #t
[m
One restriction on [1mletrec[m is very important: it must be
possible to evaluate each [4m<init>[m without assigning or referring to the
value of any [4m<variable>[m.  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
[1mletrec[m, all the [4m<init>[ms are lambda expressions and the
restriction is satisfied automatically.[m 

Other keywords, see : [1mkeyword?[m 
-----
*begin
[1m(begin <expression 1> <expression 2> ...)[m

The [4m<expression>[ms are evaluated sequentially from left to right, and
the value of the last [4m<expression>[m is returned.  This expression type
is used to sequence side effects such as input and output.
[1m
(define x 0)

(begin (set! x 5)
       (+ x 1))             =>  6

(begin (display "4 plus 1 equals ")
       (display (+ 4 1)))   =>  #t
        [mand prints[1m  4 plus 1 equals 5[m 

Other keywords, see : [1mkeyword?[m 
-----
*do
[1m(do <bindings> <clause> <body>)[m

[4m<bindings>[m should have the form [1m((<variable 1> <init 1> <step 1>) ...)[m,
[4m<clause>[m should be of the form [1m(<test> <expression> ...)[m,
and [4m<body>[m should be a sequence of one or more expressions.

[1mDo[m 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.

[1mDo[m expressions are evaluated as follows:

The [4m<init>[m expressions are evaluated in turn, the [4m<variable>[ms are
bound to fresh locations, the results of the [4m<init>[m expressions are
stored in the bindings of the [4m<variable>[ms, and then the iteration
phase begins.

Each iteration begins by evaluating [4m<test>[m; if the result is false,
then the [4m<command>[m expressions are evaluated in order for effect, the
<step> expressions are evaluated in turn, the [4m<variable>[ms are bound to
fresh locations, the results of the [4m<step>[ms are stored in the bindings
of the [4m<variable>[ms, and the next iteration begins.

If [4m<test>[m evaluates to a true value, then the [4m<expression>[ms are
evaluated from left to right and the value of the last [4m<expression>[m is
returned as the value of the [1mdo[m expression.  If no
[4m<expression>[ms are present, then the value of the [1mdo[m expression
is the value returned by [4m<test>[m.

The region of the binding of a [4m<variable>[m consists of the entire
[1mdo[m expression except for the [4m<init>[ms.  It is an error for a
[4m<variable>[m to appear more than once in the list of [1mdo[m
variables.

A [4m<step>[m may be omitted, in which case the effect is the same as if
[1m(<variable> <init> <variable>)[m had been written instead of
[1m(<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[m 

Other keywords, see : [1mkeyword?[m 
-----
*delay
[1m(delay <expression>)[m

The [1mdelay[m construct is used together with the procedure
[1mforce[m to implement lazy evaluation or call by need.
[1m(delay <expression>)[m returns an object called a promise which
at some point in the future may be asked (by the [1mforce[m
procedure) to evaluate <expression> and deliver the resulting value.

See the description of [1mforce[m for a more complete description of
[1mdelay[m.[m 

Other keywords, see : [1mkeyword?[m 
-----
*unquote
[1m(unquote <expr>)
,<expr>[m

see: [1mquasiquote[m 
-----
*unquote-splicing
[1m(unquote-splicing <expr>)
,@<expr>[m

see: [1mquasiquote[m 
-----
*quasiquote
[1m(quasiquote <template>)
`<template>[m

"Backquote" or "quasiquote" expressions are useful for constructing a
list or vector structure when most but not all of the desired
structure is known in advance.  If no commas appear within the
[4m<template>[m, the result of evaluating [1m`<template>[m is equivalent
to the result of evaluating [1m'<template>[m.  If a comma appears
within the [4m<template>[m, however, the expression following the comma is
evaluated ("unquoted") and its result is inserted into the structure
instead of the comma and the expression.  If a comma appears followed
immediately by an at-sign ([1m@[m), then the following expression must
evaluate to a list; the opening and closing parentheses of the list
are then "stripped away" and the elements of the list are inserted in
place of the comma at-sign expression sequence.

[1m`(list ,(+ 1 2) 4)          =>  (list 3 4)
(let ((name 'a)) `(list ,name ',name))
                            =>  (list a (quote a))
`(a ,(+ 1 2) ,@(map abs '(4 -5 6)) b)
                            =>  (a 3 4 5 6 b)
`(([1mfoo[m[1m ,(- 10 3)) ,@(cdr '(c)) . ,(car '(cons)))
`#(10 5 ,(sqrt 4) ,@(map sqrt '(16 9)) 8)
                            =>  #(10 5 2 4 3 8)
[m
Quasiquote forms may be nested.  Substitutions are made only for
unquoted components appearing at the same nesting level as the
outermost backquote.  The nesting level increases by one inside
each successive quasiquotation, and decreases by one inside each
unquotation.

[1m`(a `(b ,(+ 1 2) ,(foo ,(+ 1 3) d) e) f)
                            =>  (a `(b ,(+ 1 2) ,(foo 4 d) e) f)
(let ((name1 'x)
      (name2 'y))
  `(a `(b ,,name1 ,',name2 d) e))
                            =>  (a `(b ,x ,'y d) e)
[m
The notations [1m`<template>[m and [1m(quasiquote <template>)[m
are identical in all respects. [1m,<expression>[m is identical to
[1m(unquote <expression>)[m, and [1m,<expression>[m is identical
to [1m(unquote-splicing <expression>)[m.  The external syntax
generated by [1mwrite[m for two-element lists whose car is one of
these symbols may vary between implementations.

[1m(quasiquote (list (unquote (+ 1 2)) 4))
                            =>  (list 3 4)
'(quasiquote (list (unquote (+ 1 2)) 4))
                            =>  `(list ,(+ 1 2) 4)
     i.e., (quasiquote (list (unquote (+ 1 2)) 4))
[m
A syntax error will result if any of the symbols [1mquasiquote[m,
[1munquote[m, or [1munquote-splicing[m appear in positions within
a <template> otherwise than as described above.[m 

Other keywords, see : [1mkeyword?[m 
-----
*quote
[1m(quote <datum>)
'<datum>
<constant>[m

[1m(quote <datum>)[m evaluates to [4m<datum>[m. [4m<Datum>[m may be any
external representation of a Scheme object.  This notation is used to
include literal constants in Scheme code.

[1m(quote a)                   =>  a
(quote #(a b c))            =>  #(a b c)
(quote (+ 1 2))             =>  (+ 1 2)
[m
[1m(quote <datum>)[m may be abbreviated as [1m'<datum>[m.  The two
notations are equivalent in all respects.

[1m'a                          =>  a
'#(a b c)                   =>  #(a b c)
'()                         =>  ()
'(+ 1 2)                    =>  (+ 1 2)
'(quote a)                  =>  (quote a)
''a                         =>  (quote a)
[m
Numerical constants, string constants, character constants, and
boolean constants evaluate "to themselves"; they need not be quoted.

[1m'"abc"                      =>  "abc"
"abc"                       =>  "abc"
'145932                     =>  145932
145932                      =>  145932
'#t                         =>  #t
#t                          =>  #t
[m 

Other keywords, see : [1mkeyword?[m 
-----
*lambda
[1m(lambda <formals> <body>)[m

[4m<Formals>[m should be a formal arguments list as described below,
and [4m<body>[m 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.

[1m(lambda (x) (+ x x))        =>  [m[4ma procedure[m[1m
((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
[m
[4m<Formals>[m should have one of the following forms:

[1m(<variable 1> ...)[m
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.

[1m<variable>[m
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 [4m<variable>[m.

[1m(<variable 1> ... <variable n-1> . <variable n>)[m
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 [4m<variable>[m to appear more than once in [4m<formals>[m.

[1m((lambda x x) 3 4 5 6)      =>  (3 4 5 6)
((lambda (x y . z) z)
 3 4 5 6)                   =>  (5 6)
[m
Each procedure created as the result of evaluating a lambda expression
is tagged with a storage location, in order to make [1meqv?[m and
[1meq?[m work on procedures.[m 

Other keywords, see : [1mkeyword?[m 
-----
*if
[1m(if <test> <consequent> <alternate>)
(if <test> <consequent>)[m

[4m<Test>, <consequent>[m, and [4m<alternate>[m may be arbitrary expressions.

An [1mif[m expression is evaluated as follows: first, [4m<test>[m is
evaluated.  If it yields a true value, then [4m<consequent>[m is evaluated
and its value is returned.  Otherwise [4m<alternate>[m is evaluated and its
value is returned.  If [4m<test>[m yields a false value and no [4m<alternate>[m
is specified, then the result of the expression is #f.

[1m(if (> 3 2) 'yes 'no)       =>  yes
(if (> 2 3) 'yes 'no)       =>  no
(if (> 3 2)
    (- 3 2)
    (+ 3 2))                =>  1[m 

Other keywords, see : [1mkeyword?[m 
-----
*set!
[1m(set! <variable> <expression>)[m

[4m<Expression>[m is evaluated, and the resulting value is stored in the
location to which [4m<variable>[m is bound.  [4m<Variable>[m must be bound
either in some region enclosing the [1mset![m expression or at top
level.  The result of the [1mset![m expression is the stored value.

[1m(define x 2)
(+ x 1)                     =>  3
(set! x 4)                  =>  4
(+ x 1)                     =>  5[m

[1m[SWiT][m The following syntax is also permitted:
[1m
(set! <generalized variable> <expression>)
[m
The resulting value of [4m<expression>[m is the result of the
[1mset![m expression and is stored in the location expressed by the
[4m<generalized variable>[m. A [4m<generalized variable>[m is a
[4m<variable>[m or an expression that can be considered as the name
of a location. Examples of such expressions are [1m(car x),
(string-ref x 0)[m, etc.
[1m
> (define l '(a b c)) =>  l
> (set! (cdddr l) '(e f))  =>  (e f)
> l =>  (a b c e f)[m

Moreover, an expression [1m(set! (<env> <symbol>) <obj>)[m is equivalent
to [1m(set-symbol! <symbol> <obj> <env>)[m

Rationale: it is not in the spirit of Scheme to consider environments
as locations where assignment is authorized. On the contrary, distinction
between [4massignment[m and [4mbinding[m is one of the foundations of
functional programming. In swit, environments have acquired ``full
citizenship'' in order to implement the object system in a more robust
and easier way. Programming with environments (and assignments with them)
is not functional programming but object-oriented in spirit.
Consequently, the two semantics may not be confused if you know what
you are doing.

Environments are extracted from closures. In the object system of swit,
the ``classes'' are implemented as functions that return environments
that are the ``instances''. 
See [1mdefclass[m for more details about the object extension.

The valid generalized variables are:
[1m
(c...r <pair>)
([1mvector-ref[m [1m<vector> <fixnum>)
([1mstring-ref[m [1m<string> <fixnum>)
([1mqueue-ref[m [1m<queue> <fixnum>)
([1mquad-ref[m [1m<quad> <0..3>)
([1mget-mark[m [1m<pair> <0..7>)
([1mget-vmark[m [1m<vector> <0..7>)
([1mget-qmark[m [1m<queue> <0..7>)
([1mhelp[m [1m<symbol>)
([1mgetprop[m [1m<symbol>)
([1mturtle-get-position[m [1m<turtle>)
([1mturtle-get-orientation[m [1m<turtle>)
([1mlist-ref[m [1m<list> <fixnum>)
([1mlist-tail[m [1m<list> <fixnum>)
([1mlast-pair[m [1m<list>)[m 

Other keywords, see : [1mkeyword?[m 
-----
*cond
[1m(cond <clause 1> <clause 2> ...)[m

Each <clause> should be of the form [1m(<test> <expression> ...)
[mwhere <test> is any expression.  The last <clause> may be an "else
clause," which has the form [1m(else <expression 1> <expression 2> ...).
[m
A [1mcond[m expression is evaluated by evaluating the <test>
expressions of successive <clause>s in order until one of them
evaluates to a true value.  When a <test> evaluates to a true value,
then the remaining <expression>s 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 [1mcond[m expression.  If the
selected <clause> contains only the <test> and no <expression>s, then
the value of the <test> is returned as the result.  If all <test>s
evaluate to false values, and there is no else clause, then the result
of the conditional expression is #f; if there is an else clause, then
its <expression>s are evaluated, and the value of the last one is
returned.

[1m(cond ((> 3 2) 'greater)
      ((< 3 2) 'less))      =>  greater

(cond ((> 3 3) 'greater)
      ((< 3 3) 'less)
      (else 'equal))        =>  equal
[m
SWiT supports also an alternative <clause> syntax,
[1m(<test> => <recipient>)[m, where <recipient> is an expression.
If <test> evaluates to a true value, then <recipient> is evaluated.
Its value must be a procedure of one argument; this procedure is then
invoked on the value of the <test>.

[1m(cond ((assv 'b '((a 1) (b 2))) => cadr)
      (else #f))     =>  2[m 

Other keywords, see : [1mkeyword?[m 
-----
*case
[1m(case <key> <clause 1> <clause 2> ...)[m

<Key> may be any expression.  Each <clause> should have the form
[1m((<datum 1> ...) <expression 1> <expression 2> ...),
[mwhere each <datum> is an external representation of some object.

All the <datum>s must be distinct.

The last <clause> may be an "else clause," which has the form
[1m(else <expression 1> <expression 2> ...).[m

A [1mcase[m 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 [1meqv?[m) 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 [1mcase[m 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 [1mcase[m expression;
otherwise the result of the [1mcase[m expression is [1m#f[m.

[1m(case (* 2 3)
  ((2 3 5 7) 'prime)
  ((1 4 6 8 9) 'composite)) =>  composite
(case (car '(c d))
  ((a) 'a)
  ((b) 'b))                 =>  #f
(case (car '(c d))
  ((a e i o u) 'vowel)
  ((w y) 'semivowel)
  (else 'consonant))        =>  consonant[m 

Other keywords, see : [1mkeyword?[m 
-----
*and
[1m(and <test 1> ...)[m

The [4m<test>[m 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 [1m#t[m is returned.

[1m(and (= 2 2) (> 2 1))       =>  #t
(and (= 2 2) (< 2 1))       =>  #f
(and 1 2 'c '(f g))         =>  (f g)
(and)                       =>  #t[m 

Other keywords, see : [1mkeyword?[m 
-----
*or
[1m(or <test 1> ...)[m

The [4m<test>[m expressions are evaluated from left to right, and the value
of the first expression that evaluates to a true value.  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 [1m#f[m is returned.

[1m(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)[m 

Other keywords, see : [1mkeyword?[m 
-----
			BOOLEANS
*not
returns [1m#t[m if its parameter evaluates to false, and returns [1m#f[m otherwise.
[1m
(not #t)                    =>  #f
(not 3)                     =>  #f
(not (list 3))              =>  #f
(not #f)                    =>  #t
(not '())                   =>  #f
(not (list))                =>  #f
(not 'nil)                  =>  #f[m 
-----
*boolean?
returns [1m#t[m if its parameter evaluates to either [1m#t[m or [1m#f[m
and returns [1m#f[m otherwise.
[1m
(boolean? #f)               =>  #t
(boolean? 0)                =>  #f
(boolean? '())              =>  #f[m

The standard boolean objects for true and false are written as
[1m#t[m and [1m#f[m.
What really matters, though, are the objects that the Scheme conditional
expressions (if, cond, and, or, do) treat as true or false.
The phrase "a true value" (or sometimes just "true") means any
object treated as true by the conditional expressions, and the phrase
"a false value" (or "false") means any object treated as false by
the conditional expressions.

Of all the standard Scheme values, only [1m#f[m counts as false in
conditional expressions. Except for [1m#f[m, all standard Scheme
values, including [1m#t[m, pairs, the empty list, symbols, numbers,
strings, vectors, and procedures, count as true.[m 
-----
			CHARACTERS
*char?
Returns [1m#t[m if its parameter evaluates to a character, otherwise returns [1m#f[m.

Characters are objects that represent printed characters such as
letters and digits.
Characters are written using the notation #\<character>
or #\<character name>. For example:

#\a lower case letter
#\A upper case letter
#\( left parenthesis
#\  the space character
#\space the preferred way to write a space
#\newline the newline character

Case is significant in #\<character>, but not in #\<character name>.
If <character> in #\<character> is alphabetic, then the character
following <character> must be a delimiter character such as a
space or parenthesis.  This rule resolves the ambiguous case where,
for example, the sequence of characters "#\space" could be taken
to be either a representation of the space character or a
representation of the character "#\s" followed by a representation
of the symbol "pace."

Characters written in the #\ notation are self-evaluating.
That is, they do not have to be quoted in programs. Moreover,
characters have a unique internal representation (see [1meq?[m).

Some of the procedures that operate on characters ignore the difference
between upper case and lower case.  The procedures that ignore case have
"-ci" (for "case insensitive") embedded in their names.

[1m[SWiT][m Character codes are in the range 0 to 65535. The
valid character names are : [4mbackspace, tab, newline, formfeed,
return, escape,[m and [4mspace[m. Two-bytes characters are written and can be
read with the syntax [1m#\ll[m, where [1ml[m is any letter. 8 bits characters
can also be entered in octal (in the range [1m#\000[m and [1m#\377[m), e.g. [1m#\125[m
is equivalent to [1m#\U[m.
Extended characters cannot be read in octal.
Characters (8 bits or 16 bits) can also be read in hexadecimal,
the two or four hexa-numbers must follow an `x', e.g. [1m#\xbf5a[m.

See:
[1mchar=?[m			[1mchar<?[m
[1mchar>?[m			[1mchar<=?[m
[1mchar>=?[m			[1mchar-ci=?[m
[1mchar-ci<?[m		[1mchar-ci>?[m
[1mchar-ci<=?[m		[1mchar-ci>=?[m
[1mchar-alphabetic?[m	[1mchar-numeric?[m
[1mchar-whitespace?[m	[1mchar-upper-case?[m
[1mchar-lower-case?[m	[1mchar->integer[m
[1minteger->char[m		[1mchar-upcase[m
[1mchar-downcase[m 
-----
*char=?
*char<?
*char>?
*char<=?
*char>=?
[1mchar=?[m, [1mchar<?[m, [1mchar>?[m, [1mchar<=?[m, [1mchar>=?[m: these procedures impose
a total ordering on the set of characters. It is guaranteed that
under this ordering:

      The upper case characters are in order. For example,
      [1m(char<? #\A #\B)[m returns [1m#t[m.
      The lower case characters are in order. For example,
      [1m(char<? #\a #\b)[m returns [1m#t[m.
      The digits are in order. For example, [1m(char<? #\0 #\9)[m returns [1m#t[m.
      Either all the digits precede all the upper case letters,
      or vice versa.
      Either all the digits precede all the lower case letters,
      or vice versa.[m 
-----
*char-ci=?
*char-ci<?
*char-ci>?
*char-ci<=?
*char-ci>=?
[1mchar-ci=?[m, [1mchar-ci<?[m, [1mchar-ci>?[m, [1mchar-ci<=?[m, [1mchar-ci>=?[m: these
procedures are similar to [1mchar=?[m et cetera, but they treat upper case
and lower case letters as the same. For example, [1m(char-ci=? #\A #\a)[m
returns [1m#t[m.[m 
-----
*char-alphabetic?
*char-numeric?
*char-whitespace?
*char-upper-case?
*char-lower-case?
[1mchar-alphabetic?[m, [1mchar-numeric?[m, [1mchar-whitespace?[m, [1mchar-upper-case?[m,
[1mchar-lower-case?[m: these procedures return [1m#t[m if their arguments
are alphabetic, numeric, whitespace, upper case, or lower case
characters, respectively, otherwise they return [1m#f[m. The following
remarks, which are specific to the ASCII character set, are
intended only as a guide: The alphabetic characters are the 52 upper
and lower case letters. The numeric characters are the ten decimal
digits. The whitespace characters are space, tab, line feed,
form feed, and carriage return.[m 
-----
*char->integer
*integer->char
Given a character, [1mchar->integer[m returns an exact integer
representation of the character. Given an exact integer that
is the image of a character under [1mchar->integer[m, [1minteger->char[m
returns that character. These procedures implement injective
order isomorphisms between the set of characters under the [1mchar<=?[m
ordering and some subset of the integers under the <= ordering.
That is, if [1m(char<=? a b) => #t[m and [1m(<= x y) => #t[m and [1mx[m and [1my[m
are in the domain of [1minteger->char[m, then :
[1m
(<= (char->integer a)
    (char->integer b))       =>  #t

(char<=? (integer->char x)
         (integer->char y))  =>  #t[m 
-----
*char-upcase
*char-downcase
[1mchar-upcase[m, [1mchar-downcase[m: these procedures return a character
char2 such that [1m(char-ci=? char char2)[m. In addition, if char is
alphabetic, then the result of [1mchar-upcase[m is upper case and the
result of [1mchar-downcase[m is lower case.[m 
-----
			CONTROL FEATURES
*procedure?
Returns [1m#t[m if its argument is a procedure, otherwise returns [1m#f[m.
[1m
(procedure? car)            =>  #t
(procedure? 'car)           =>  #f
(procedure? (lambda (x) (* x x)))
                            =>  #t
(procedure? '(lambda (x) (* x x)))
                            =>  #f
(call-with-current-continuation procedure?)
                            =>  #t[m

When a procedure appears at the head of an expression, the expression
is a [4mprocedure call[m:

[1m(<operator> <operand 1> ...)[m

A procedure call is written by simply enclosing in parentheses
expressions for the procedure to be called and the arguments to be
passed to it.  The operator and operand expressions are evaluated in
turn and the resulting procedure is passed the resulting arguments.
[1m
(+ 3 4)                     =>  7
((if #f + *) 3 4)           =>  12
[m
A number of procedures are available as the values of variables in the
initial environment; for example, the addition and multiplication
procedures in the above examples are the values of the variables
[1m+[m and [1m*[m. New procedures are created by evaluating lambda
expressions.

Procedure calls are also called [1mcombinations[m.

Note:  In many dialects of Lisp, the empty combination,
[1m()[m, is a legitimate expression.  In Scheme, combinations must
have at least one subexpression, so [1m()[m is not a syntactically
valid expression.

See:
[1mapply[m		[1mmap[m		[1mfor-each[m
[1mmap*[m		[1mappend-map[m	[1mappend-map![m
[1mappend-map*[m	[1mappend-map*![m	[1mcall/cc[m
[1mprimitive?[m	[1mclosure?[m	[1mforce[m
[1mcontinuation?[m	[1mdisassemble[m	[1mpromise?[m
[1mcall-with-current-continuation[m	
-----
*apply
Its first argument must be a procedure and args must be a list.
The first (essential) form calls proc with the elements of args as the
actual arguments. The second form is a generalization of the
first that calls [1mproc[m with the elements of the list
[1m(append (list arg1 ...) args)[m as the actual arguments.
[1m
(apply + (list 3 4))        =>  7

(define compose
  (lambda (f g)
    (lambda args
      (f (apply g args)))))

((compose sqrt *) 12 75)    =>  30[1m[m 
-----
*map
The lists must be proper lists, and the procedure must be a procedure
taking as many arguments as there are lists. If more than one list is
given, then they must all be the same length. [1mMap[m applies the
procedure 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 the procedure is applied to the elements of the lists is also
from left to right.
[1m
(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)))           =>  (1 2 3)[m

Note: [1m[SWiT][m If the given lists are not the same length, the
exception [1merror:size[m will be raised.[m 
-----
*append-map
[1m[SWiT][m As with [1mmap[m the procedure is applied element-wise
on the lists, but the results must also be lists. These lists are
appended to form the final result.
If the given lists are not of the same length, the exception [1merror:size[m
is raised. If the results are not proper lists, the exception ex:type
is raised.[m 
-----
*append-map!
[1m[SWiT][m Same as append-map, but the intermediate results are
destructively appended. It is called mapcan in Common Lisp (and other
lisp dialects) and is classicly used to filter objects from a list.

(append-map! (lambda (x) (if (number? x) (list x) '())) '(1 a 0 b 4))
 => (1 0 4)[m 
-----
*map*
[1m[SWiT][m Equivalent to :
[1m(append! (map <proc> <list> <list> ...) <pair>)[m
but more efficient.[m 
-----
*append-map*
[1m[SWiT][m Equivalent to :
[1m(append! (append-map <proc> <list> <list> ...) <obj>)[m
but more efficient.[m 
-----
*append-map!*
[1m[SWiT][m Equivalent to :
[1m(append! (append-map! <proc> <list> <list> ...) <obj>)[m
(but more efficient).[m 
-----
*for-each
The arguments to [1mfor-each[m are like the arguments to [1mmap[m, but
[1mfor-each[m calls the procedure for its side effects rather than for its values.
[1mfor-each[m calls the procedure on the elements of the lists in
order from the first element to the last, and the value returned by
[1mfor-each[m is always the last value.
[1m
(let ((v (make-vector 5)))
  (for-each (lambda (i)
              (vector-set! v i (* i i)))
            '(0 1 2 3 4))
  v)                        =>  16[m 
-----
*force
If no value has been computed for the promise, then a value is
computed and returned. The value of the promise is cached (or "memoized")
so that if it is forced a second time, the previously computed
value is returned.
[1m
(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[m and [1mdelay[m 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.
[1m
(define count 0)
(define p
  (delay (begin (set! count (+ count 1))
                (if (> count x)
                    count
                    (force p)))))
(define x 5)
p                           =>  a promise
(force p)                   =>  6
p                           =>  a promise, still
(begin (set! x 10)
       (force p))           =>  6
[m
Here is a possible implementation of [1mdelay[m and [1mforce[m. Promises are implemented here as procedures of no arguments, and [1mforce[m simply
calls its argument:
[1m
(define force
  (lambda (object)
    (object)))[m

We define the expression
[1m
(delay <expression>)[m

to have the same meaning as the procedure call
[1m
(make-promise (lambda () <expression>))[m,

where [1mmake-promise[m is defined as follows:
[1m
(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))))))))[m

Rationale: A promise may refer to its own value, as in the last
example above. Forcing such a promise may cause the promise to be forced
a second time before the value of the first [1mforce[m has been computed.
This complicates the definition of [1mmake-promise[m.

Calling [1mforce[m on an object that is not a promise simply returns the object.

There is no means by which a promise can be operationally distinguished
from its forced value. That is, expressions like the following evaluate
to [1m#f[m:
[1m
      (eqv? (delay 1) 1)          =>  #f
      (pair? (delay (cons 1 2)))  =>  #f[m

The value of a promise is forced "implicitly" by primitive procedures
like [1mcdr[m and [1m+[m:
[1m
      (+ (delay (* 3 7)) 13)      =>  error[m 
-----
*call/cc
*call-with-current-continuation
The argument must be a procedure of one argument. The procedure
[1mcall-with-current-continuation[m packages up the current
continuation as an "escape procedure" and passes it as an argument to
the procedure. 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 proc 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
[1mcall-with-current-continuation[m. If all real programs were as simple as
these examples, there would be no need for a procedure with the
power of [1mcall-with-current-continuation[m.
[1m
(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[m

see also: [1mtry[m 
 
-----
*promise?
[1m[SWiT][m Returns [1m#t[m iff its parameter evaluates to a promise.[m 
-----
*primitive?
[1m[SWiT][m Returns [1m#t[m iff its parameter evaluates to a primitive.[m 
-----
*closure?
Returns [1m#t[m iff its parameter evaluates to a closure.[m 
-----
*continuation?
Returns [1m#t[m iff its parameter evaluates to a continuation.[m 
-----
*disassemble
[1m[SWiT][m Returns the source code of the given closure.
Bug: does not disassemble the environment of the closure.[m 
-----
			EQUIVALENCE PREDICATES
*eqv?
The [1meqv?[m procedure defines a useful equivalence relation on objects.
Briefly, it returns [1m#t[m if its two arguments should normally be
regarded as the same object. This relation is left slightly open to
interpretation, but the following partial specification of [1meqv?[m holds
for all implementations of Scheme.

The [1meqv?[m procedure returns [1m#t[m if:

      obj1 and obj2 are both [1m#t[m or both [1m#f[m.

      obj1 and obj2 are both symbols and
[1m
      (string=? (symbol->string obj1)
                (symbol->string obj2))
                                  =>  #t[m

      obj1 and obj2 are both numbers, are numerically equal
      (see =), and are either both exact or both inexact.

      obj1 and obj2 are both characters and are the same character
      according to the [1mchar=?[m procedure.

      both obj1 and obj2 are the empty list.

      obj1 and obj2 are pairs, vectors, or strings that denote the
      same locations in the store.

      obj1 and obj2 are procedures whose location tags are equal.

The [1meqv?[m procedure returns [1m#f[m if:

      obj1 and obj2 are of different types.

      one of obj1 and obj2 is [1m#t[m but the other is [1m#f[m.

      obj1 and obj2 are symbols but
[1m
      (string=? (symbol->string obj1)
                (symbol->string obj2))
                                  =>  #f[m

      one of obj1 and obj2 is an exact number but the other is an
      inexact number.

      obj1 and obj2 are numbers for which the [1m=[m procedure returns [1m#f[m.

      obj1 and obj2 are characters for which the [1mchar=?[m procedure returns [1m#f[m.

      one of obj1 and obj2 is the empty list but the other is not.

      obj1 and obj2 are pairs, vectors, or strings that denote distinct
      locations.

      obj1 and obj2 are procedures that would behave differently (return
      a different value or have different side effects) for some arguments.
[1m
(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[m

The following examples illustrate cases in which the above rules
do not fully specify the behavior of [1meqv?[m. All that can be said about
such cases is that the value returned by [1meqv?[m must be a boolean.
[1m
(eqv? "" "")                =>  #t
(eqv? '#() '#())            =>  #t
(eqv? (lambda (x) x)
      (lambda (x) x))       =>  #t
(eqv? (lambda (x) x)
      (lambda (y) y))       =>  #t[1m

The next set of examples shows the use of [1meqv?[m 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.
[1m
(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))
                            =>  #f

(letrec ((f (lambda () (if (eqv? f g) 'both 'f)))
         (g (lambda () (if (eqv? f g) 'both 'g))))
  (eqv? f g))
                            =>  #f

(letrec ((f (lambda () (if (eqv? f g) 'f 'both)))
         (g (lambda () (if (eqv? f g) 'g 'both))))
  (eqv? f g))
                            =>  #f[m

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 [1meqv?[m on constants is sometimes implementation-dependent.
[1m
(eqv? '(a) '(a))            =>  #f
(eqv? "a" "a")              =>  #f
(eqv? '(b) (cdr '(a b)))    =>  #f
(let ((x '(a)))
  (eqv? x x))               =>  #t[m

Rationale: The above definition of [1meqv?[m 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.[m 
-----
*eq?
[1mEq?[m is similar to [1meqv?[m except that in some cases it is capable of
discerning distinctions finer than those detectable by [1meqv?[m.

[1mEq?[m and [1meqv?[m are guaranteed to have the same behavior on symbols,
booleans, the empty list, pairs, and non-empty strings and vectors.
[1mEq?[m's behavior on numbers and characters is implementation-dependent,
but it will always return either true or false, and will return true
only when [1meqv?[m would also return true. [1mEq?[m may also behave differently
from [1meqv?[m on empty vectors and empty strings.
[1m
(eq? 'a 'a)                 =>  #t
(eq? '(a) '(a))             =>  #f
(eq? (list 'a) (list 'a))   =>  #f
(eq? "a" "a")               =>  #f
(eq? "" "")                 =>  #t
(eq? '() '())               =>  #t
(eq? 2 2)                   =>  #f
(eq? #\A #\A)               =>  #t
(eq? car car)               =>  #t
(let ((n (+ 2 3)))
  (eq? n n))                =>  #t
(let ((x '(a)))
  (eq? x x))                =>  #t
(let ((x '#()))
  (eq? x x))                =>  #t
(let ((p (lambda (x) x)))
  (eq? p p))                =>  #t[m

Rationale: It will usually be possible to implement [1meq?[m much more
efficiently than [1meqv?[m, for example, as a simple pointer comparison instead
of as some more complicated operation. One reason is that it may not
be possible to compute [1meqv?[m of two numbers in constant time,
whereas [1meq?[m implemented as pointer comparison will always finish in
constant time. [1mEq?[m may be used like [1meqv?[m in applications using
procedures to implement objects with state since it obeys the same
constraints as [1meqv?[m.[m 
-----
*equal?
[1mEqual?[m recursively compares the contents of pairs, vectors, and strings,
applying [1meqv?[m on other objects such as numbers and symbols. A rule of
thumb is that objects are generally [1mequal?[m if they print the same.
[1mEqual?[m may fail to terminate if its arguments are circular data
structures.
[1m
(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))     =>  #t[m 
-----
*graph-equal?
[1m[SWiT][m Graphs can be compared with this function.

(define g1 (let ((x '(a b))) (cons x x))) =>  g1
(define g2 '((a b) a b)) =>  g2
(equal? g1 g2)  =>  #t
(graph-equal? g1 g2)  =>  #f[m 
-----
			INPUT AND OUTPUT
*read
[1mRead[m 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 [4m<input-port>[m, updating
[4m<input-port>[m 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 remains open, and further attempts to read will also return an
end of file object.  If an end of file is encountered after the
beginning of an object's external representation, but the external
representation is incomplete and therefore not parsable, an error is
signalled.

The [4m<input-port>[m argument may be omitted, in which case it defaults to
the value returned by ([1mcurrent-input-port[m).  It is an error to
read from a closed port.

Here is an informal account of some of the lexical conventions used in
writing Scheme (and SWiT) programs.

Upper and lower case forms of a letter are never distinguished
except within character and string constants.  For example, [1mFoo[m
is the same identifier as [1mFOO[m, and [1m#x1AB[m is the same
number as [1m#X1ab[m.

Most identifiers allowed by other programming languages are also
acceptable to Scheme.  The precise rules for forming identifiers vary
among implementations of Scheme, but in all implementations a sequence
of letters, digits, and "extended alphabetic characters" that begins
with a character that cannot begin a number is an identifier.  In
addition, [1m+[m, [1m-[m, and [1m...[m are identifiers.
Here are some examples of identifiers:
[1m
lambda                   q
list->vector             soup
+                        V17a
<=?                      a34kTMNs
the-word-recursion-has-many-meanings
[m
Extended alphabetic characters may be used within identifiers as if
they were letters.  The following are extended alphabetic characters:
[1m
+ - . * / < = > ! ? : $ % _ & ~ ^
[m
Identifiers have several uses within Scheme programs:

 -- Certain identifiers are reserved for use as syntactic keywords
    (see below).
 -- Any identifier that is not a syntactic keyword may be used as a
    variable (but see below).
 -- When an identifier appears as a literal or within a literal, it is
    being used to denote a symbol (see [1msymbol?[m).

Some identifiers are syntactic keywords (see [1mkeyword?[m to get
their list), and cannot be used as variables if the global variable
*keyword* is [1m#t[m (but [1m#f[m is chosen default).

Whitespace characters are POSIX's one: space, newline, return,
line-feed (vertical tab), form-feed, and tab. Whitespace is used for
improved readability and as necessary to separate tokens from each
other, a token being an indivisible lexical unit such as an identifier
or number, but is otherwise insignificant.  Whitespace may occur
between any two tokens, but not within a token.  Whitespace may also
occur inside a string, where it is significant.

A semicolon ([1m;[m) indicates the start of a comment.
The comment continues to the end of the line on which the semicolon
appears.  Comments are invisible to Scheme, but the end of the line is
visible as whitespace.  This prevents a comment from appearing in the
middle of an identifier or number.
[1m
;;; The FACT procedure computes the factorial
;;; of a non-negative integer.
(define fact
  (lambda (n)
    (if (= n 0)
        1        ;Base case: return 1
        (* n (fact (- n 1))))))
[m

For a description of the notations used for numbers, see number?.

[1m. + -[m
   These are used in numbers, and may also occur anywhere in an
   identifier except as the first character.  A delimited plus or
   minus sign by itself is also an identifier. A delimited period (not
   occurring within a number or identifier) is used in the notation
   for pairs (see [1mpair?[m), and to indicate a rest-parameter in a
   formal parameter list (see [1mlambda[m). A delimited sequence of three
   successive periods is also an identifier.


[1m( )[m
   Parentheses are used for grouping and to notate lists

[1m'[m
   The single quote character is used to indicate literal data (see [1mquote[m).

[1m`[m
   The backquote character is used to indicate almost-constant
   data (see [1mquasiquote[m).

[1m, ,@[m
   The character comma and the sequence comma at-sign are used in
   conjunction with backquote (see [1mquasiquote[m).

[1m"[m
   The double quote character is used to delimit strings (see [1mstring?[m).

[1m\ [m
   Backslash is used in the syntax for character constants (see [1mchar?[m) 
   and as an escape character within string constants (see [1mstring?[m).

[1m#[m
   Sharp sign is used for a variety of purposes depending on
   the character that immediately follows it:

[1m#t #f[m
   These are the boolean constants (see [1mboolean?[m).

[1m#\[m
   This introduces a character constant (see [1mchar?[m).

[1m#([m
   This introduces a vector constant (see [1mvector?[m). Vector
   constants are terminated by `)'.

[1m#e #i #b #o #d #x[m
   These are used in the notation for numbers (see [1mnumber?[m).

The following are not standard in Scheme (but added in SWiT):

[1m[ ][m
   Left and right square brackets can be used in place of parenthesis
   to clarify the code.

[1m{ }[m
   Curly braces are used to delimit quads (see [1mquad?[m).

[1m#![m 
   Start comment up to the end of line, same as `;'.

[1m#@[m 
   Source the Tcl file following it.

[1m#|[m 
   Starts a `super' comment that is terminated by [1m|#[m.

[1m#.[m 
   Evaluates at read-time the expression following it.

[1m#[[m 
   This introduces a queue constant (see [1mqueue?[m). Queue
   constants are terminated by `]'.

[1m##unbound ##eof[m 
   The unbound object and the end-of-file object.

Finally, on the top level only, when a [1m#[m is followed by a
space, the line is interpreted as a shell command.[m 
-----
*read-char
Returns the next character available from <input-port>, updating
the <input-port> to point to the following character.  If no more
characters are available, an end of file object is returned.
<input-port> may be omitted, in which case it defaults to the value
returned by ([1mcurrent-input-port[m).[m 
-----
*peek-char
Returns the next character available from <input-port>, without
updating the <input-port> to point to the following character. If no
more characters are available, an end of file object is
returned. <input-port> may be omitted, in which case it defaults to
the value returned by ([1mcurrent-input-port[m).[m 
-----
*char-ready?
Returns [1m#t[m if a character is ready on <input-port> and
returns [1m#f[m otherwise.  If [1mchar-ready[m returns [1m#t[m
then the next read-char operation on <input-port> is guaranteed not to
hang.  If the <port> is at end of file then [1mchar-ready?[m returns
[1m#t[m. <input-port> may be omitted, in which case it defaults to
the value returned by ([1mcurrent-input-port[m).[m 
-----
*read-line
[1mSWiT[m Returns the next line available from <input-port>,
updating the <input-port> to point to the following line.  The line is
returned without the terminating newline character. If no more
characters are available, an end of file object is returned.
<input-port> may be omitted, in which case it defaults to the value
returned by ([1mcurrent-input-port[m).

Implementation limit: 16k is the maximum length of a line.[m 
-----
*eof-object?
Returns [1m#t[m iff the value of its parameter is an end of file
object.
[1m[SWiT][m An end of file object can be read in with the syntax [1m##eof[m.[m 
-----
*string->port
[1m[SWiT][m Creates an input/output port from a mutable string.[m 
-----
*call-with-io-string
[1m[SWiT][m Similar to [1mcall-with-file[m, the second argument 
is a procedure of one argument bound to the port created from [4m<string>[m.[m 
-----
*with-input-from-string
[1m[SWiT][m Similar to the primitive [1mwith-input-from-file[m but input
is performed from a string-port created with [4m<string>[m.[m 
-----
*with-output-to-string
[1m[SWiT][m Similar to the primitive [1mwith-output-to-file[m but output
is performed on a string port created with [4m<string>[m.[m 
-----
*port-string
[1m[SWiT][m Returns the string attached to the (string) port given in argument.[m 
-----
*call-with-input-file
*call-with-output-file
*call-with-file
The second argument should be a procedure of one argument, and
[4m<string>[m should be a string naming a file.  For
[1mcall-with-input-file[m, the file must already exist; for
[1mcall-with-output-file[m, if the file already exists, the port
is positionned at the beginning. These procedures call the procedure
with one argument: the port obtained by opening the named file
for input or 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.[m 
-----
*port?
Returns [1m#t[m iff its parameter evaluates to a port.

Ports represent input and output devices.  To Scheme, an input port is a
Scheme object that can deliver characters upon command,
while an output port is a Scheme object that can accept characters.

See:
[1mread[m				[1mread-char[m
[1mread-line[m			[1mpeek-char[m
[1mchar-ready?[m			[1meof-object?[m
[1mwrite[m				[1mdisplay[m
[1mwrite-char[m			[1mnewline[m
[1minput-port?[m			[1moutput-port?[m
[1mread-write-port?[m		[1msocket-port?[m
[1mdescr->port[m			[1mcall-with-output-file[m
[1mcall-with-input-file[m		[1mcall-with-file[m
[1mwith-output-to-file[m		[1mwith-input-from-file[m
[1mcurrent-input-port[m		[1mcurrent-output-port[m
[1mcurrent-error-port[m		[1mopen-input-file[m
[1mopen-file[m			[1mopen-output-file[m
[1mstring-port?[m			[1mcall-with-io-string[m
[1mwith-output-to-string[m		[1mwith-input-from-string[m
[1mport-string[m			[1mstring->port[m
[1mclose-input-port[m		[1mclose-output-port[m
[1mclose-port[m			[1mseek-set[m
[1mseek-cur[m			[1mseek-end[m
[1mtranscript-on[m			[1mtranscript-off[m

See also [1msocket?[m 
-----
*input-port?
Returns [1m#t[m if its parameter evaluates to an input-port
otherwise returns [1m#f[m.[m 
-----
*output-port?
Returns [1m#t[m if its parameter evaluates to an output-port
otherwise returns [1m#f[m.[m 
-----
*descr->port
[1m[SWiT][m A port is displayed as #<port n>, n being the descriptor
returned by the system. Such a syntax cannot be read, but an
open port can be retreived from this descriptor number with
this primitive.[m 
-----
*read-write-port?
[1m[SWiT][m Returns [1m#t[m iff its parameter evaluates to an input/output port.[m 
-----
*string-port?
[1m[SWiT][m Returns [1m#t[m iff its parameter evaluates to a string port.[m 
-----
*current-input-port
Returns the current default input port.[m 
-----
*current-output-port
Returns the current default output port.[m 
-----
*current-error-port
[1m[SWiT][m Returns the current default error port.[m 
-----
*with-input-from-file
*with-output-to-file
The second argument must be a procedure of no arguments, and [4m<string>[m
must be a string naming a file.  For [1mwith-input-from-file[m, the file must
already exist; for [1mwith-output-to-file[m, if the file already exists.
the port is positionned at the beginning. The file is opened for input
or output, an input or output port connected to it is made the default
value returned by ([1mcurrent-input-port[m) or ([1mcurrent-output-port[m),
and the procedure is called with no arguments.  When the procedure
returns, the port is closed and the previous default is restored.
[1mWith-input-from-file[m and [1mwith-output-to-file[m return the
value yielded by the procedure.[m 
-----
*open-file
[1m[SWiT][m Open a file for reading or writing.[m 
-----
*open-input-file
Takes a string naming 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.[m 
-----
*open-output-file
Takes a string naming 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 port is positionned at
the beginning.
--
*close-input-port
*close-output-port
*close-port
Closes the file associated with the port, rendering it incapable of
delivering or accepting characters.

These routines have no effect if the file has already been closed.
The value returned is [1m#t[m if the <port> was not already closed and
[1m#f[m otherwise.

[1m[SWiT][m Returns [1m#t[m if the port was not already closed and [1m#f[m
if it was already closed.[m 
-----
*write
Writes a written representation of its argument.  Strings
that appear in the written representation are enclosed in doublequotes,
and within those strings backslash and doublequote characters are
escaped by backslashes. A call to [1m(write <obj> <output-port>)[m
returns [1m#t[m. The (output) port argument may be omitted, in which
case it defaults to the value returned by ([1mcurrent-output-port[m).[m 
-----
*display
Writes a representation of its argument.  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. A call to [1m(display <obj> <output-port>) [m
returns [1m#t[m.
The (output) port argument may be omitted, in which case it defaults
to the value returned by ([1mcurrent-output-port[m).[m 
-----
*newline
Writes an end of line to <output-port>.  Exactly how this is done differs
from one operating system to another.  Returns an unspecified value.
The [4m<output-port>[m argument may be omitted, in which case it defaults to the
value returned by ([1mcurrent-output-port[m).[m 
-----
*write-char
Writes the character [4m<char>[m (not an external representation of the
character) to the given [4m<output-port>[m and returns [1m#t[m. The 
(output) port argument may be omitted, in which case it defaults to the value
returned by ([1mcurrent-output-port[m).[m 
-----
*transcript-on
*transcript-off
Filename [4m<string>[m must be a string naming an output file to be
created. The effect of [1m(transcript-on <string>)[m 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 [1m(transcript-off)[m, which closes the
transcript file.  Only one transcript may be in progress at any time.[m 
-----
*seek-set
*seek-cur
*seek-end
[1m[SWiT][m seek-set, seek-cur, seek-end : these functions set or return
(when the optional argument is not given) the port position from which
next read or write operation will be performed. These functions are
not valid on socket ports.[m 
-----
*load
Filename [4m<string>[m should be a string naming an existing file
containing SWiT compiled or source code. The [1m(load <string>)[m call reads
expressions and definitions from the file named [4m<string>[m (possibly
prepended by the string  [1m*load-path* [m) and evaluates them
sequentially. The results of the expressions are never printed
unless the global variable *verbose* is true.
The load procedure does not affect the values
returned by ([1mcurrent-input-port[m) and ([1mcurrent-output-port[m).
Load returns the value of the last expression.[m 
-----
*file-exists?
[1m[SWiT][m Returns [1m#t[m iff the file already exists.[m 
-----
*system
[1m[SWiT][m Executes a command in a subshell.[m 
-----
*chdir
[1m[SWiT][m Changes the current process directory.[m 
-----
*quit
[1m[SWiT][m Don't try ``bye'' or ``exit'' : it won't work. Sending the
``quit'' signal (usually by typing Ctr-\) also terminates the session.[m 
-----
			MISC. PRIMITIVES
*getenv
[1m[SWiT][m Returns the list of all environment strings of the form var = val.[m 
-----
*date
[1m[SWiT][m Returns the current date.[m 
-----
*pwd
[1m[SWiT][m Returns the current working directory.[m 
-----
*current-env
[1m[SWiT][m Returns the current environment.[m 
-----
*closure-env
[1m[SWiT][m Returns the local environment of its argument.[m 
-----
*extend-env
[1m[SWiT][m The second environment is extended with the first one.
This function is used to define simple inheritance in the object system.[m 
-----
*promise-env
[1m[SWiT][mWhen a delayed expression is evaluated, the current
environment is stored into the ``promise''. That environment is
returned by a call to this function, even if the promise has been
``forced''.[m 
-----
*environment?
[1m[SWiT][m Returns [1m#t[m iff its argument evaluates to an environment.

See:
[1mclosure-env[m		[1mpromise-env[m
[1mcurrent-env[m		[1mextend-env[m
[1mparent-env[m		[1mget-env-names[m
[1mframe->alist[m		[1menv-depth[m 
-----
*env-depth
[1m[SWiT][m Returns the depth of the environment [4m<env>[m.
[1m
> (let* ((x 4) (y x)) (env-depth (closure-env)))
            =>  2[m 
-----
*parent-env
[1m[SWiT][m Returns the parent environment of [4m<env>[m or raise
[1merror:env[m if no parent environment exists (i.e. already at
top-level).[m 
-----
*frame->alist
[1m[SWiT][m Returns an a-list representing the first frame of the
environment [4m<env>[m.[m 
-----
*get-env-names
[1m[SWiT][m Returns all the names of bound identifiers in [4m<env>[m.
Used in some utilities of the object system (that is based on
environments).[m 
-----
*macro?
[1m[SWiT][m Returns [1m#t[m if [4m<symbol>[m is bound to
a macro definition.
[1m
(defmacro incr (x) `(set! ,x (+ ,x 1)))  => incr
(macro? 'incr)  =>  #t[m

See:
[1mdefmacro[m		
[1mmacro-expand[m
[1mmacro-expand1[m 
-----
*macro-expand1
[1m[SWiT][m Expands a macro-call. Used to debug macros.
Example: [1m
> (macro-expand1 '(while #t (display "yes\n")))
(do () ((not #t)) (display "yes
"))[m

See also: [1mmacro-expand[m 
-----
*macro-expand
[1m[SWiT][m Recursively expands all macro-calls in an expression.
Example:[1m
> (macro-expand '(let ((x 0)) (while (< x 10) (incr! x))))
(let ((x 0)) (do () ((not (< x 10))) (set! x (+ x 1))))[m

See also: [1mmacro-expand1[m 
-----
*gc-collect
[1m[SWiT][m Force a garbage collection.[m 
-----
*gc-heap-size
[1m[SWiT][m Returns the current heap size in bytes.[m 
-----
*gc-expand
[1m[SWiT][m Asks for an expansion of the heap, argument in kilo-bytes.[m 
-----
*raise
[1m[SWiT][m Raise an exception whose name is [4m<symbol>[m. If an
argument follows, its value will be passed to the handler of the
exception if the handler is a procedure, otherwise it is ignored.

Exceptions are [4mraised[m either when an error occurs or
intentionally with a call to the primitive [1mraise[m. When the
exception is an error an appropriate message is sent.
When [1mraise[m is called, it can also send a value. This value is
usually a string describing the cause of the exception but can be
any value.

Errors raise predefined exceptions:
[1merror:type[m is raised when an argument has a wrong type,
[1merror:range[m is raised when an index is out of range (e.g. in
vectors or strings),
[1merror:arity[m is raised when a primitive is called with wrong
number of arguments,
[1merror:unbound[m is raised when trying to evaluate an unbound
symbol,
[1merror:math[m is raised when an arithmetic error occurs,
[1merror:io[m is raised when an input or output operation cannot
be done,
[1merror:read[m is raised with all syntax errors,
[1merror:continuation[m is raised when a continuation is lost,
[1merror:env[m can only be raised within the primitive
parent-env[m (when no parent environment exists), but this
primitive is essential in the implemention of the object subsytem.
[1merror:length[m is raised when list arguments have not the same
length as required (e.g. in [1mmap[m, [1mfor-each[m, etc.)
[1merror:unknown[m is raised in all other situations (unknown or
unclassified errors).[m 
-----
*error
[1m[SWiT] error[m raised the exception [1merror:unknown[m.
[4m<string>[m is the message of the error, the second argument is optional
and can be any expression.[m 
-----
*cerror
[1m[SWiT][m Like [1merror[m, but in this case, the environment can be
examined and the error may be recovered by an assignment. The second argument
(that normally shows the expression where the error occured) is
displayed after the message [4m<string>[m. To reevaluate the
expression, the break loop must be exited by entering [1m#t[m, on
the other hand, the computation is to be abandonned if [1m#f[m is entered.
[1m
> (define (safe-sqrt n) (and (negative? n) (cerror "argument is negative !" `(sqrt ,n))) (sqrt n))
safe-sqrt : <num> -> <num>
> (safe-sqrt -4)
argument is negative !
in: '(sqrt -4)
break >> n
-4
break >> (set! n 4)
4
break >> #t
2 : <num>[1m[m 
-----
*clock
[1m[SWiT][m Returns the elapsed CPU process time in milliseconds since the
beginning of the session.[m 
-----
*pause
[1m[SWiT][m Waits for a while. The argument represents milliseconds.[m 
-----
*mutable->immutable
[1m[SWiT][m Cast its argument (a pair, a vector, a queue or a quad)
to immutable. Inverse of [1mimmutable->mutable[m.[m 
-----
*immutable->mutable
[1m[SWiT][m Cast its argument (a pair, a vector, a queue or a quad)
to mutable. Inverse of [1mmutable->immutable[m.[m 
-----
*mutable?
[1m[SWiT][m Returns [1m#t[m iff its parameter evaluates to a mutable object.
Only [4mpairs, vectors, queues[m and [4mquads[m are concerned.[m 
-----
*identity
[1m[SWiT][m The identity function, same as [1m(lambda (x) x).[m 
-----
*version
[1m[SWiT][m Prints the current version of SWiT.[m 
-----
			TURTLE GRAPHICS AND BEZIER
*bezier?
[1m[SWiT][m Returns [1m#t[m iff its parameter evaluates to a quadratique bezier
curve.

See:
[1mbezier-distance[m 
-----
*bezier-distance
[1m[SWiT][m Returns an approximation of the distance between a given point and a
quadratic bezier curve.[m 
-----
*turtle?
[1m[SWiT][m Returns [1m#t[m iff its parameter evaluates to a turtle.

Turtle graphics is a very simple graphics model yet a powerful means to draw 
complex and structured objects. A turtle is a new type (i.e. an opaque structure). 
It has a [4mposition[m, an [4morientation[m, a [4mstack[m and a [4mpath[m. 
The pair [4m(position, orientation)[m is called ``the state'' of the turtle 
and can be saved on its stack. A [4mposition[m is a point in 3D-space,
functions that operate on 3D-points and 3D-vectors are provided (see [1mquad?[m).
An [4morientation[m is a 3D-frame ``attached'' to the turtle
so that the turtle is always looking in the y-direction of that frame,
the right side of the turtle is the y-direction and above the turtle 
there is the z-direction. An orientation is represented by a quaternion
because in 3D-space quaternions are associated with rotations.  
Pratically, the quaternions are kept ``behind the scene'' and the
movements of the turtle are defined relatively to its current orientation
by specifying simple actions such as ``turn upright 20''
or ``roll left 50'', etc.

A turtle moves forward in the direction [4my[m of its current
orientation (i.e. frame). After each move, the new position is
recorded into its current path. The path is a list a ``contiguous''
turtle positions, the head of which is the current position, other
elements are past positions. The path is cleared when the turtle
``jumps''. There are two operations that are considered as jumps : an
assignment of a new position and a restore of a (former) state that
was saved on the turtle stack. Turtle changes of orientation or moves
are not jumps.

The drawing of the path normally takes place just before a jump (after,
it's too late anyway). Common implementations of turtle graphics
assume a drawing operation each time the turtle moves. Drawing of the
path as a whole instead of drawing at each move not only is more
efficient, but also gives the possibility to define filled areas
and smooth curves with the path.

Former turtle states can be remembered by saving them on the stack.
This is useful for branching in a recursively defined drawing
or for defining local states in structured objects.
The stack can grow unlimitedly as it is implemented as a list.

The list of states of a turtle could also represent a moving frame for
an animated object or camera. In this case, only the turtle stack is useful
and the path is normally be ignored because no drawing occurs.

See:
[1mmake-turtle[m			[1mturtle-move![m
[1mturtle-left![m			[1mturtle-right![m
[1mturtle-up![m			[1mturtle-down![m
[1mturtle-roll-left![m		[1mturtle-roll-right![m
[1mturtle-get-position[m		[1mturtle-set-position![m
[1mturtle-get-orientation[m	[1mturtle-set-orientation![m
[1mturtle-get-path[m		[1mturtle-clear-path![m
[1mturtle-get-stack[m		[1mturtle-clear-stack![m
[1mturtle-save![m			[1mturtle-restore![m
[1mturtle-heading[m			[1mset-visu![m
[1mnorm->world[m			[1mworld->norm[m 
-----
*make-turtle
[1m[SWiT][m A turtle object whose initial position is [4m<point>[m and initial
orientation is [4m<quater>[m is returned. When these arguments are
not given, default values are set: the origin of world coordinate for
the the position, and the Y direction for the orientation.
Upon creation, the turtle stack is empty, and the turtle path is
the list whose only element is the initial position.[m 
-----
*turtle-get-position
[1m[SWiT][m Returns the current position of [4m<turtle>[m. It may be
``dangerous'' to perform destructive operations on this point because
of side effects on the path and possibly on the stack.[m 
-----
*turtle-set-position!
[1m[SWiT][m The turtle is given a new position and its path is reset with
this new position as its origin (normally, a drawing operation would
be performed before calling this function).[m 
-----
*turtle-get-orientation
[1m[SWiT][m Returns the current orientation of [4m<turtle>[m. Performing
destructive operations on this quaternion is not recommended...[m 
-----
*turtle-set-orientation!
[1m[SWiT][m Set a new orientation for the turtle. The path is not changed.[m 
-----
*turtle-move!
[1m[SWiT][m The turtle is ``moved'' in the direction of its current
orientation by a distance of [4m<real>[m. The turtle is given a new
position that is added to its path. Normally, the second argument (the
distance) is positive, but this is not required: when it is negative,
the turtle moves backwards.[m 
-----
*turtle-get-path
[1m[SWiT][m Returns the current path of [4m<turtle>[m.[m 
-----
*turtle-clear-path!
[1m[SWiT][m Clears the path of [4m<turtle>[m. The path will only contains the
current position.[m 
-----
*turtle-left!
[1m[SWiT][m The turtle orientation is turned to the left with a [4m<real>[m
amount of degrees.[m 
-----
*turtle-right!
[1m[SWiT][m The turtle orientation is turned to the right with a [4m<real>[m
amount of degrees.[m 
-----
*turtle-up!
[1m[SWiT][m The turtle orientation is turned up with a [4m<real>[m amount of
degrees.[m 
-----
*turtle-down!
[1m[SWiT][m The turtle orientation is turned down with a [4m<real>[m amount of
degrees.[m 
-----
*turtle-roll-left!
[1m[SWiT][m The turtle orientation is rolled left with a [4m<real>[m amount of
degrees.[m 
-----
*turtle-roll-right!
[1m[SWiT][m The turtle orientation is rolled right with a [4m<real>[m amount of
degrees.[m 
-----
*turtle-heading
[1m[SWiT][m When the second argument is not given or zero, a (unit) vector
is returned that gives the direction of the turtle move. When the
second argument is given (and not zero), a point is returned giving
the position the turtle would have if it is moved for that distance.[m 
-----
*turtle-save!
[1m[SWiT][m Push the current state on the turtle stack.[m 
-----
*turtle-restore!
[1m[SWiT][m The turtle state becomes the state that is at the top of
its stack. The turtle path is cleared and initialized with the new
position. Finally the stack is popped. The exception error:type" is
raised if the stack was empty.[m 
-----
*turtle-get-stack
[1m[SWiT][m Returns the current stack of [4mturtle[m.[m 
-----
*turtle-clear-stack!
[1m[SWiT][m Clear the turtle stack.[m 
-----
*world->norm
*norm->world
[1m[SWiT][m [1mworld->norm[m and [1mnorm->world[m are reciprocal
conversion functions between normalize coordinate system and world
coordinate system. The argument can be a point ``at infinity''.[m 
-----
*set-visu!
[1m[SWiT][m Set the visualisation frame with origin at [4m<point>[m, horizontal
orientation with [4mtheta = quad[x][m, [4mphi = quad[y][m, [4meye = quad[z][m and
[4mfocal = quad[w][m.

Graphics objects are build in 3D-space but visualized on a 2D-screen.
For that purpose, a transform is needed. It is common to
decompose this transform in several independent steps: first, the
objects are defined in world coordinates; second, a frame -- called
the visualisation frame -- is chosen to define from what point of
view and orientation and scale the scene shall be viewed; third,
a perspective is applied as if the scene was shot by a (virtual)
camera that lies on the Z-axis of the visualisation frame; finally,
the photo taken by the camera is mapped onto the screen (more
precisely, onto one or several windows).[m 
-----
	                     NUMBERS
*number?
*complex?
*real?
*rational?
*integer?
[1mnumber?, complex?, real?, rational?, integer?[m: these numerical
type predicates can be applied to any kind of argument, including
non-numbers. They return [1m#t[m if the object is of the named type,
and otherwise they return [1m#f[m. In general, if a type predicate
is true of a number then all higher type predicates are also true of
that number. Consequently, if a type predicate is false of a number,
then all lower type predicates are also false of that number.

If z is an inexact complex number, then [1m(real? z)[m is true if
and only if [1m(zero? (imag-part z))[m is true. If x is an inexact
real number, then [1m(integer? x)[m is true if and only if [1m(= x (round x))[m.
[1m
(complex? 3+4i)             =>  #t
(complex? 3)                =>  #t
(real? 3)                   =>  #t
(real? -2.5+0.0i)           =>  #t
(real? #e1e10)              =>  #t
(rational? 6/10)            =>  #t
(rational? 6/3)             =>  #t
(integer? 3+0i)             =>  #t
(integer? 3.0)              =>  #t
(integer? 8/4)              =>  #t[m

Note: The behavior of these type predicates on inexact numbers is
unreliable, since any inaccuracy may affect the result.

Note: In many implementations the [1mrational?[m procedure will be the
same as [1mreal?[m, and the [1mcomplex?[m procedure will be the
same as [1mnumber?[m, but unusual implementations may be able to
represent some irrational numbers exactly or may extend the number
system to support some kind of non-complex numbers.

Note: Remember that an integer can be exact or inexact, and
[1m(integer? 2.0)[m returns [1m#t[m. Big inexact numbers that are
entered with a non zero fractional part may be represented internally
without this fractional part (as a C "double"), and [1minteger?[m will
respond [1m#t[m with such numbers (roughly, this occurs when a
number has an absolute value greater than 10^16). This lack of
accuracy has a similar consequence on number functions or predicates
that require an integer argument.

[1mAbout Scheme numbers[m

Numerical computation has traditionally been neglected by the Lisp
community. Until Common Lisp there was no carefully thought out
strategy for organizing numerical computation, and with the exception
of the MacLisp system [PITMAN83] little effort was made to execute
numerical code efficiently. This report recognizes the excellent work
of the Common Lisp committee and accepts many of their
recommendations. In some ways this report simplifies and generalizes
their proposals in a manner consistent with the purposes of Scheme.

It is important to distinguish between the mathematical numbers, the
Scheme numbers that attempt to model them, the machine representations
used to implement the Scheme numbers, and notations used to write
numbers. This report uses the types number, complex, real, rational,
and integer to refer to both mathematical numbers and Scheme
numbers. Machine representations such as fixed point and floating
point are referred to by names such as fixnum and flonum.

[4mNumerical types[m

Mathematically, numbers may be arranged into a tower of subtypes in
which each level is a subset of the level above it:

     number
     complex
     real
     rational
     integer

For example, 3 is an integer. Therefore 3 is also a rational, a real,
and a complex. The same is true of the Scheme numbers that model
3. For Scheme numbers, these types are defined by the predicates
[1mnumber?[m, [1mcomplex?[m, [1mreal?[m, [1mrational?[m, and [1minteger?[m.

There is no simple relationship between a number's type and its
representation inside a computer. Although most implementations of
Scheme will offer at least two different representations of 3, these
different representations denote the same integer.

Scheme's numerical operations treat numbers as abstract data, as
independent of their representation as possible. Although an
implementation of Scheme may use fixnum, flonum, and perhaps other
representations for numbers, this should not be apparent to a casual
programmer writing simple programs.

It is necessary, however, to distinguish between numbers that are
represented exactly and those that may not be. For example, indexes
into data structures must be known exactly, as must some polynomial
coefficients in a symbolic algebra system. On the other hand, the
results of measurements are inherently inexact, and irrational numbers
may be approximated by rational and therefore inexact
approximations. In order to catch uses of inexact numbers where exact
numbers are required, Scheme explicitly distinguishes exact from
inexact numbers. This distinction is orthogonal to the dimension of
type.

[4mExactness[m

Scheme numbers are either exact or inexact. A number is exact if it
was written as an exact constant or was derived from exact numbers
using only exact operations. A number is inexact if it was written as
an inexact constant, if it was derived using inexact ingredients, or
if it was derived using inexact operations. Thus inexactness is a
contagious property of a number.

If two implementations produce exact results for a computation that
did not involve inexact intermediate results, the two ultimate results
will be mathematically equivalent. This is generally not true of
computations involving inexact numbers since approximate methods such
as floating point arithmetic may be used, but it is the duty of each
implementation to make the result as close as practical to the
mathematically ideal result.

Rational operations such as [1m+[m should always produce exact results when
given exact arguments. If the operation is unable to produce an exact
result, then it may either report the violation of an implementation
restriction or it may silently coerce its result to an inexact
value. See section Implementation restrictions.

With the exception of [1minexact->exact[m, the operations described in this
section must generally return inexact results when given any inexact
arguments. An operation may, however, return an exact result if it can
prove that the value of the result is unaffected by the inexactness of
its arguments. For example, multiplication of any number by an exact
zero may produce an exact zero result, even if the other argument is
inexact.

[4mImplementation restrictions[m

Implementations of Scheme are not required to implement the whole
tower of subtypes given in section Numerical types, but they must
implement a coherent subset consistent with both the purposes of the
implementation and the spirit of the Scheme language. For example, an
implementation in which all numbers are real may still be quite
useful.

Implementations may also support only a limited range of numbers of
any type, subject to the requirements of this section. The supported
range for exact numbers of any type may be different from the
supported range for inexact numbers of that type. For example, an
implementation that uses flonums to represent all its inexact real
numbers may support a practically unbounded range of exact integers
and rationals while limiting the range of inexact reals (and therefore
the range of inexact integers and rationals) to the dynamic range of
the flonum format. Furthermore the gaps between the representable
inexact integers and rationals are likely to be very large in such an
implementation as the limits of this range are approached.

An implementation of Scheme must support exact integers throughout the
range of numbers that may be used for indexes of lists, vectors, and
strings or that may result from computing the length of a list,
vector, or string. The [1mlength[m, [1mvector-length[m, and [1mstring-length[m
procedures must return an exact integer, and it is an error to use
anything but an exact integer as an index. Furthermore any integer
constant within the index range, if expressed by an exact integer
syntax, will indeed be read as an exact integer, regardless of any
implementation restrictions that may apply outside this
range. Finally, the procedures listed below will always return an
exact integer result provided all their arguments are exact integers
and the mathematically expected result is representable as an exact
integer within the implementation:
[1m
+            -             *
quotient     remainder     modulo
max          min           abs
numerator    denominator   gcd
lcm          floor         ceiling
truncate     round         rationalize
expt[m

Implementations are encouraged, but not required, to support exact
integers and exact rationals of practically unlimited size and
precision, and to implement the above procedures and the / procedure
in such a way that they always return exact results when given exact
arguments. If one of these procedures is unable to deliver an exact
result when given exact arguments, then it may either report a
violation of an implementation restriction or it may silently coerce
its result to an inexact number. Such a coercion may cause an error
later.

An implementation may use floating point and other approximate
representation strategies for inexact numbers.

This report recommends, but does not require, that the IEEE 32-bit and
64-bit floating point standards be followed by implementations that
use flonum representations, and that implementations using other
representations should match or exceed the precision achievable using
these floating point standards [IEEE].

In particular, implementations that use flonum representations must
follow these rules: A flonum result must be represented with at least
as much precision as is used to express any of the inexact arguments
to that operation. It is desirable (but not required) for potentially
inexact operations such as sqrt, when applied to exact arguments, to
produce exact answers whenever possible (for example the square root
of an exact 4 ought to be an exact 2). If, however, an exact number is
operated upon so as to produce an inexact result (as by sqrt), and if
the result is represented as a flonum, then the most precise flonum
format available must be used; but if the result is represented in
some other way then the representation must have at least as much
precision as the most precise flonum format available.

Although Scheme allows a variety of written notations for numbers, any
particular implementation may support only some of them. For example,
an implementation in which all numbers are real need not support the
rectangular and polar notations for complex numbers. If an
implementation encounters an exact numerical constant that it cannot
represent as an exact number, then it may either report a violation of
an implementation restriction or it may silently represent the
constant by an inexact number.

[4mSyntax of numerical constants[m

A number may be written in binary, octal, decimal, or hexadecimal by
the use of a radix prefix. The radix prefixes are #b (binary), #o
(octal), #d (decimal), and #x (hexadecimal). With no radix prefix, a
number is assumed to be expressed in decimal.

A numerical constant may be specified to be either exact or inexact by
a prefix. The prefixes are #e for exact, and #i for inexact. An
exactness prefix may appear before or after any radix prefix that is
used. If the written representation of a number has no exactness
prefix, the constant may be either inexact or exact. It is inexact if
it contains a decimal point, an exponent, or a "#" character in the
place of a digit, otherwise it is exact.

In systems with inexact numbers of varying precisions it may be useful
to specify the precision of a constant. For this purpose, numerical
constants may be written with an exponent marker that indicates the
desired precision of the inexact representation. The letters s, f, d,
and l specify the use of short, single, double, and long precision,
respectively. (When fewer than four internal inexact representations
exist, the four size specifications are mapped onto those
available. For example, an implementation with two internal
representations may map short and single together and long and double
together.) In addition, the exponent marker e specifies the default
precision for the implementation. The default precision has at least
as much precision as double, but implementations may wish to allow
this default to be set by the user.
[1m
3.14159265358979F0[m
        Round to single --- [1m3.141593[m
[1m0.6L0[m
        Extend to long --- [1m.600000000000000[m

[4mNumerical operations[m

The reader is referred to section Entry format for a summary of the
naming conventions used to specify restrictions on the types of
arguments to numerical routines.

The examples used in this section assume that any numerical constant
written using an exact notation is indeed represented as an exact
number. Some examples also assume that certain numerical constants
written using an inexact notation can be represented without loss of
accuracy; the inexact constants were chosen so that this is likely to
be true in implementations that use flonums to represent inexact
numbers.

See:
[1mfixnum?[m			[1mbignum?[m
[1mexact?[m			[1minexact?[m
[1mzero?[m			[1mpositive?[m
[1mnegative?[m		[1modd?[m
[1meven?[m			[1mprime?[m
[1mexact->inexact[m		[1minexact->exact[m
[1mfloor[m			[1mceiling[m
[1mtruncate[m		[1mround[m
[1m=[m			[1m<[m
[1m>[m			[1m<=[m
[1m>=[m			[1m+[m
[1m-[m			[1m/[m
[1m*[m			[1mmax[m
[1mmin[m			[1mabs[m
[1mquotient[m		[1mremainder[m
[1mmodulo[m			[1mgcd[m
[1mlcm[m			[1mexp[m
[1mexpt[m			[1msin[m
[1mcos[m			[1mtan[m
[1masin[m			[1macos[m
[1matan[m			[1mlog[m
[1msinh[m			[1mcosh[m
[1mtanh[m			[1masinh[m
[1macosh[m			[1matanh[m
[1mfact[m			[1mhypot[m
[1msqrt[m			[1mrandom[m
[1msrandom[m			[1mcbrt[m
[1mnumber->string[m		[1mstring->number[m 
-----
*fixnum?
[1m[SWiT][m Returns [1m#t[m iff its parameter evaluates to a
fixnum. Fixnums are `small' exact integers that can be used as index in
strings, vectors, lists, etc. Currently, the absolute value of a
fixnum is less than 2^15. Consequently, strings, vectors, queues and
lists cannot have more than 32767 elements.[m 
-----
*bignum?
[1m[SWiT][m Returns [1m#t[m iff its parameter evaluates to a
bignum. A bignum is an exact integer that is not a fixnum.[m 
-----
*exact?
*inexact?
Scheme numbers are either exact or inexact. A number is exact if
it was written as an exact constant or was derived from exact numbers
using only exact operations. A number is inexact if it was written
as an inexact constant, if it was derived using inexact ingredients,
or if it was derived using inexact operations. Thus inexactness is a
contagious property of a number.

If two implementations produce exact results for a computation that
did not involve inexact intermediate results, the two ultimate results
will be mathematically equivalent. This is generally not true of
computations involving inexact numbers since approximate methods
such as floating point arithmetic may be used, but it is the duty
of each implementation to make the result as close as practical to
the mathematically ideal result.

Rational operations such as [1m+[m should always produce exact results
when given exact arguments. If the operation is unable to produce an
exact result, then it may either report the violation of an implementation
restriction or it may silently coerce its result to an inexact value.

With the exception of inexact->exact, the numeric operations must
generally return inexact results when given any inexact arguments.
An operation may, however, return an exact result if it can prove
that the value of the result is unaffected by the inexactness of
its arguments. For example, multiplication of any number by an
exact zero may produce an exact zero result, even if the other
argument is inexact.[m 
-----
*=
*<
*>
*<=
*>=
[1m=, <, >, <=, >=,[m these procedures return [1m#t[m if their arguments are
(respectively): equal, monotonically increasing, monotonically
decreasing, monotonically nondecreasing, or monotonically
nonincreasing.

These predicates are required to be transitive.

Note: The traditional implementations of these predicates in Lisp-like
languages are not transitive.

Note: While it is not an error to compare inexact numbers using
these predicates, the results may be unreliable because a small inaccuracy
may affect the result; this is especially true of [1m=[m and [1mzero?[m.
When in doubt, consult a numerical analyst.[m 
-----
*zero?
*positive?
*negative?
*odd?
*even?
[1mzero?, positive?, negative?, odd?, even?[m, these numerical predicates
test a number for a particular property, returning [1m#t[m or [1m#f[m.[m 
-----
*prime?
[1m[SWiT][m Probabilistic probability test. The probability of a
false positive answer is approximatively 10^-15.[m 
-----
*+
**
These procedures return the sum or product of their arguments.
[1m
(+ 3 4)                     =>  7
(+ 3)                       =>  3
(+)                         =>  0
(* 4)                       =>  4
(*)                         =>  1[m 
-----
*-
*/
With two or more arguments, these procedures return the difference
or quotient of their arguments, associating to the left. With one
argument, however, they return the additive or multiplicative
inverse of their argument.
[1m
(- 3 4)                     =>  -1
(- 3 4 5)                   =>  -6
(- 3)                       =>  -3
(/ 3 4 5)                   =>  3/20
(/ 3)                       =>  1/3[m 
-----
*max
*min
maximum or minimum of their arguments.
[1m
(max 3 4)                   =>  4   [m ; exact
[1m(max 3.9 4)                 =>  4.0 [m ; inexact

Note: If any argument is inexact, then the result will also be
inexact (unless the procedure can prove that the inaccuracy is
not large enough to affect the result, which is possible only
in unusual implementations). If min or max 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.[m 
-----
*expt
Returns z1 raised to the power z2:
[1m
(define (expt z1 z2) (exp z2 (log z1)))

(expt 0 0)[m is defined to be equal to 1.[m 
-----
*abs
Abs returns the magnitude of its argument.
[1m
(abs -7)                    =>  7[m 
-----
*floor
*ceiling
*truncate
*round
Rounding procedures return integers. [1mFloor[m returns the largest
integer not larger than x. [1mCeiling[m returns the smallest integer
not smaller than x. [1mTruncate[m returns the integer closest to x
whose absolute value is not larger than the absolute value of x.
[1mRound[m returns the closest integer to x, rounding to even when x
is halfway between two integers.

Rationale: Round rounds to even for consistency with the default
rounding mode specified by the IEEE floating point standard.

Note: If the argument to one of these procedures is inexact, then
the result will also be inexact. If an exact value is needed, the
result should be passed to the [1minexact->exact[m procedure.
[1m
(floor -4.3)                =>  -5.0
(ceiling -4.3)              =>  -4.0
(truncate -4.3)             =>  -4.0
(round -4.3)                =>  -4.0

(floor 3.5)                 =>  3.0
(ceiling 3.5)               =>  4.0
(truncate 3.5)              =>  3.0
(round 3.5)                 =>  4.0 [m ; inexact
[1m
(round 7/2)                 =>  4  [m  ; exact
[1m(round 7)                   =>  7[m 
-----
*gcd
*lcm
Returns the greatest common divisor or least common multiple
of their arguments. The result is always non-negative.
[1m
(gcd 32 -36)                =>  4
(gcd)                       =>  0
(lcm 32 -36)                =>  288
(lcm 32.0 -36)              =>  288.0  [m; inexact
[1m(lcm)                       =>  1[m 
-----
*quotient
*remainder
*modulo
Number-theoretic (integer) division: For positive integers n1 and n2,
if n3 and n4 are integers such that
[1m
(= n1 (+ (* n2 n3) n4)),
(<= 0 n4), and
(< n4 n2).[m

Then
[1m
(quotient n1 n2)            =>  n3
(remainder n1 n2)           =>  n4
(modulo n1 n2)              =>  n4[m

For integers n1 and n2 with n2 not equal to 0,
[1m
(= n1 (+ (* n2 (quotient n1 n2))
               (remainder n1 n2)))
                            =>  #t[m

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 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:
[1m
(modulo 13 4)               =>  1
(remainder 13 4)            =>  1

(modulo -13 4)              =>  3
(remainder -13 4)           =>  -1

(modulo 13 -4)              =>  -3
(remainder 13 -4)           =>  1

(modulo -13 -4)             =>  -1
(remainder -13 -4)          =>  -1

(remainder -13 -4.0)        =>  -1.0 [m ; inexact[m 
-----
*fact
[1m[SWiT][m Returns the factorial of [4m<exact-int>[m. Of course, the
argument must be positive (and not too big).[m 
-----
*log
*asin
*acos
*atan
*sinh
*cosh 
*tanh
*asinh
*acosh
*atanh
Transcendental functions.
Log computes the natural logarithm of z (not the base ten logarithm).
Asin, acos, and atan compute arcsine , arccosine , and arctangent ,
respectively. The two-argument variant of atan computes
[1m(angle (make-rectangular x y))[m, even in implementations
that don't support general complex numbers.

In general, the mathematical functions log, arcsine, arccosine,
and arctangent are multiply defined. For nonzero real x, the value
of [1m(log x)[m is defined to be the one whose imaginary part lies in
the range -pi (exclusive) to pi (inclusive). [1m(log 0)[m is undefined.
The value of [1m(log z)[m when z is complex is defined according to the
formula:
[1m
(define (log z) (+ (log (magnitude z)) (* +i (angle z))))[m

With log defined this way, the values of arcsin, arccos, and
arctan are according to the following formulae:
[1m
(define (asin z) (* -i (log (+ (* +i z) (sqrt (- 1 (* z z)))))))

(define (acos z) (- (/ pi 2) (asin z)))

(define (atan z) (/ (log (/ (+ 1 (* +i z)) (- 1 (* +i z)))) (* +i 2))[m

When it is possible these procedures produce a real result from a real
argument.

[1m[SWiT] [1msinh[m, [1mcosh[m, [1mtanh[m, [1masinh[m, [1macosh[m, [1matanh[m are the hyperbolic
transcendental functions.[m 
-----
*cbrt
[1m[SWiT][m Returns the cube root of its argument.[m 
-----
*hypot
[1m[SWiT][m Returns [1m(sqrt (+ (* <num1> <num1>) (* <num2> <num2>)))[m.[m 
-----
*sqrt
Returns the principal square root of z. The result will have either
positive real part, or zero real part and non-negative imaginary part.
[1m[SWiT][m When the argument is a perfect square and is exact, an
exact result is returned.[m 
-----
*random
[1m[SWiT][m Returns a pseudo-random exact integer in the range 0 to 2^31.
To get a pseudo-random real number in the range [0,1],
call: [1m(/ (random) 2147483647.0)[m.[m 
-----
*srandom
[1m[SWiT][m Initializes the pseudo-random generator with [4m<exact-int>[m.
If [4m<exact-int>[m is greater than 2^31, it is truncated (the first
unsigned ``limb'' of the bignum is taken). The value of the seed is
returned.[m 
-----
*exact->inexact
[1mExact->inexact[m returns an inexact representation of z. The value
returned is the inexact number that is numerically closest to the
argument. If an exact argument has no reasonably close inexact
equivalent, then a violation of an implementation restriction may
be reported.[m 
-----
*inexact->exact
[1mInexact->exact[m returns an exact representation of z. The value
returned is the exact number that is numerically closest to the
argument. If an inexact argument has no reasonably close exact
equivalent, then a violation of an implementation restriction may
be reported.[m 
-----
*number->string
Radix must be an exact integer, either 2, 8, 10, or 16. If omitted,
radix defaults to 10. The procedure [1mnumber->string[m takes a number and a
radix and returns as a string an external representation of the
given number in the given radix such that
[1m
(let ((number number)
      (radix radix))
  (eqv? number
        (string->number (number->string number
                                        radix)
                        radix)))[m

is true. It is an error if no possible result makes this expression true.

If number 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 [1mnumber->string[m never contains an explicit
radix prefix.

Note: The error case can occur only when number is not a complex number
or is a complex number with a non-rational real or imaginary part.

Rationale: If number is an inexact number represented using flonums,
and the radix is 10, then the above expression is normally satisfied by
a result containing a decimal point. The unspecified case allows for
infinities, NaNs, and non-flonum representations.[m 
-----
*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 [1mstring->number[m returns [1m#f[m.
[1m
(string->number "100")      =>  100
(string->number "100" 16)   =>  256
(string->number "1e2")      =>  100.0
(string->number "15##")     =>  1500.0[m

Note: Although [1mstring->number[m is an essential procedure, an implementation
may restrict its domain in the following ways.
[1mString->number[m is permitted to return [1m#f[m whenever string contains an
explicit radix prefix. If all numbers supported by an implementation
are real, then [1mstring->number[m is permitted to return [1m#f[m whenever string
uses the polar or rectangular notations for complex numbers. If all
numbers are integers, then [1mstring->number[m may return [1m#f[m whenever the
fractional notation is used. If all numbers are exact, then
[1mstring->number[m may return [1m#f[m 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 [1mstring->number[m may return [1m#f[m whenever
a decimal point is used.[m 
-----
			PAIRS AND LISTS
*cons
Returns a newly allocated pair whose car is the value of its first
parameter and whose cdr is the value of its second parameter.  The
pair is guaranteed to be different (in the sense of [1meqv?[m) from every
existing object.
[1m
(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)[m 
-----
*pair?
Returns [1m#t[m iff its parameter evaluates to a pair.
[1m
(pair? '(a . b))            =>  #t
(pair? '(a b c))            =>  #t
(pair? '())                 =>  #f
(pair? '#(a b))             =>  #f[m

A [4mpair[m (sometimes called a [4mdotted pair[m) is a record
structure with two fields called the car and cdr fields (for
historical reasons).  Pairs are created by the procedure
[1mcons[m. The car and cdr fields are accessed by the procedures
[1mcar[m and [1mcdr[m.  The car and cdr fields are assigned by the
procedures [1mset-car![m and [1mset-cdr![m.

Pairs are used primarily to represent lists.  A list can be defined
recursively as either the empty list or a pair whose cdr is a list.
More precisely, the set of lists is defined as the smallest set X such
that :

 -- The empty list is in X.
 -- If list is in X, then any pair whose cdr field contains
    list is also in X.

The objects in the car fields of successive pairs of a list are the
elements of the list.  For example, a two-element list is a pair whose
car is the first element and whose cdr is a pair whose car is the
second element and whose cdr is the empty list.  The length of a list
is the number of elements, which is the same as the number of pairs.

The empty list is a special object of its own type (it is not a pair);
it has no elements and its length is zero.

[4mNote:[m  The above definitions imply that all lists have finite
length and are terminated by the empty list.

The most general notation (external representation) for Scheme pairs
is the "dotted" notation [1m(c1 . c2)[m where c1 is the value of the
car field and c2 is the value of the cdr field.  For example [1m(4 . 5)[m
is a pair whose car is 4 and whose cdr is 5.  Note that [1m(4 . 5)[m
is the external representation of a pair, not an expression
that evaluates to a pair.

A more streamlined notation can be used for lists: the elements of the
list are simply enclosed in parentheses and separated by spaces.  The
empty list is written [1m()[m. For example,

[1m(a b c d e)
[m
and

[1m(a . (b . (c . (d . (e . ())))))
[m
are equivalent notations for a list of symbols.

A chain of pairs not ending in the empty list is called an
[4mimproper list[m.  Note that an improper list is not a list. The
list and dotted notations can be combined to represent improper lists:

[1m(a b c . d)
[m
is equivalent to

[1m(a . (b . (c . d)))
[m
Whether a given pair is a list depends upon what is stored in the cdr
field.  When the [1mset-cdr![m procedure is used, an object can be a
list one moment and not the next:

[1m> (define x (list 'a 'b 'c))  =>  x
> (define y x)		      =>  y
> y                           =>  (a b c)
> (list? y)                   =>  #t
> (set-cdr! x 4)              =>  4
> x                           =>  (a . 4)
> (eqv? x y)                  =>  #t
> y                           =>  (a . 4)
> (list? y)                   =>  #f
> (set-cdr! x x)              =>  (a . 4)
> (list? x)                   =>  #f
[m
Within literal expressions and representations of objects read by the
[1mread[m procedure, the forms [1m'<datum>[m,[1m`<datum>[m,
[1m,<datum>[m, and [1m,@<datum>[m denote two-element lists
whose first elements are the symbols [1mquote[m, [1mquasiquote[m,
[1munquote[m, and [1munquote-splicing[m, respectively.  The second
element in each case is <datum>.  This convention is supported so that
arbitrary Scheme programs may be represented as lists. That is,
according to Scheme's grammar, every <expression> is also a
<datum>. Among other things, this permits the use of the [1mread[m
procedure to parse Scheme programs.[m 

See:
[1mcons[m		[1mcar[m		[1mcdr[m
[1mcadr[m		[1mset-car![m	[1mset-cdr![m
[1mnull?[m		[1mlist?[m		[1mmember[m
[1massoc[m		[1mreverse[m		[1mappend[m
[1mlist-tail[m	[1mlist-ref[m	[1mlist[m
[1mlength[m		[1mlast-pair[m	[1mrassoc[m
[1mcopy-list[m	[1mappend![m		[1mreverse![m
[1mlist-insert![m	[1mcopy-graph[m	[1mcopy-tree[m
[1mremove[m		[1mremove![m		[1mcons*[m
[1macons[m		[1msubst[m		[1msublis[m 
-----
*car
Returns the contents of the car field of the given pair.
The exception [1merror:type[m is raised on attempt to take the car of the
empty list.
[1m
(car '(a b c))              =>  a
(car '((a) b c d))          =>  (a)
(car '(1 . 2))              =>  1
(car '())                   =>  error[m 
-----
*cdr
Returns the contents of the cdr field of given pair.
The exception [1merror:type[m is raised on attempt to take the cdr of the
empty list.
[1m
(cdr '((a) b c d))          =>  (b c d)
(cdr '(1 . 2))              =>  2
(cdr '())                   =>  error[m 
-----
*set-car!
Stores the value of the second argument in the car field of the given
pair. The stored value is returned by [1mset-car![m.
[1m
(define (f) (list 'not-a-constant-list))
(define (g) '(constant-list))
(set-car! (f) 3)            =>  3
(set-car! (g) 3)            =>  error[m 
-----
*set-cdr!
Stores the value of the second argument in the cdr field of the given
pair. The stored value is returned by [1mset-cdr![m.[m 
-----
*caar
*cddr
*cdar
*cadr
*caaar
*caadr
*cadar
*cdaar
*caddr
*cdadr
*cddar
*cdddr
*caaaar
*cddddr
*cdddar
*cddadr
*cdaddr
*cadddr
*cdaaar
*cadaar
*caadar
*caaadr
*caaddr
*cadadr
*caddar
*cdadar
*cddaar
*cdaadr
Composition of car and cdr, where
for example [1mcaddr[m could be defined by :
[1m
   (define caddr (lambda (x) (car (cdr (cdr x)))))[m.

Arbitrary compositions, up to four deep, are provided.  There are
twenty-eight of these procedures in all.[m 
-----
*null?
Returns [1m#t[m if its parameter evaluates to the empty list,
otherwise returns [1m#f[m. The empty list is a unique value.[m
The empty list is used to define proper lists and multi-branched
trees. See the predicate [1mlist?[m. Note: there are no built-in
predicate for multi-branched trees, but it can be easily defined in Scheme.[m 
-----
*list?
Returns [1m#t[m if its parameter evaluates to a list, otherwise
returns [1m#f[m. By definition, all lists have finite length and are
terminated by the empty list.
[1m
        (list? '(a b c))    =>  #t
        (list? '())         =>  #t
        (list? '(a . b))    =>  #f
        (let ((x (list 'a)))
          (set-cdr! x x)
          (list? x))        =>  #f[m 
-----
*memq
*memv
*member
These procedures return the first sublist of list whose car is obj,
where the sublists of list are the non-empty lists returned by
[1m(list-tail list k)[m for [1mk[m less than the length of list. If obj
does not occur in list, then [1m#f[m (not the empty list) is returned.
[1mMemq[m uses [1meq?[m to compare obj with the elements of list, while
memv uses [1meqv?[m and member uses [1mequal?[m.
[1m
(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
(member (list 'a)
        '(b (a) c))         =>  ((a) c)
(memq 101 '(100 101 102))   =>  #f
(memv 101 '(100 101 102))   =>  (101 102)[m 
-----
*assq
*assv
*assoc
Alist (for "association list") must be a list of pairs. These
procedures find the first pair in alist whose car field is obj,
and returns that pair. If no pair in alist has obj as its car,
then [1m#f[m (not the empty list) is returned. [1mAssq[m uses [1meq?[m to compare
obj with the car fields of the pairs in alist, while [1massv[m uses
[1meqv?[m and assoc uses [1mequal?[m.
[1m
(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
(assoc (list 'a) '(((a)) ((b)) ((c))))
                            =>  ((a))
(assq 5 '((2 3) (5 7) (11 13)))
                            =>  #f
(assv 5 '((2 3) (5 7) (11 13)))
                            =>  (5 7)[m 
-----
*reverse
Returns a newly allocated list consisting of the elements of list
in reverse order.
[1m
(reverse '(a b c))          =>  (c b a)
(reverse '(a (b c) d (e (f))))
                            =>  ((e (f)) d (b c) a)[m 
-----
*list-tail
Returns the sublist of list obtained by omitting the first k elements.
[1mList-tail[m could be defined by
[1m
(define list-tail
  (lambda (x k)
    (if (zero? k)
        x
        (list-tail (cdr x) (- k 1)))))[m

Note: in fact, the list argument can be an improper list.[m 
-----
*last-pair
[1m[SWiT][m Returns the last pair of its argument.
[1m
 (last-pair '(a b c . d))  =>  (c . d)[m 
-----
*list-ref
Returns the kth element of list. This is the same as the car of
[1m(list-tail list k)[m
[1m
(list-ref '(a b c d) 2)     =>  c
(list-ref '(a b c d)
          (inexact->exact (round 1.8)))
                            =>  c[m

Note: in fact, the list argument can be an improper list.[m 
-----
*length
Returns the length of list.

(length '(a b c))           =>  3
(length '(a (b) (c d e)))   =>  3
(length '())                =>  0

[1m[SWiT][m As an extension, when [4m<list>[m is improper, the negated
number of its cdr cells is returned. Moreover, [1m#f[m is returned
when it is a cyclic list.[m 
-----
*list
Returns a newly allocated list of its arguments.
[1m
(list 'a (+ 3 4) 'c)        =>  (a 7 c)
(list)                      =>  ()[m 
-----
*append
Returns a list consisting of the elements of the first list followed
by the elements of the other lists.
[1m
(append '(x) '(y))          =>  (x y)
(append '(a) '(b c d))      =>  (a b c d)
(append '(a (b)) '((c)))    =>  (a (b) (c))[m

The resulting list is always newly allocated, except that it shares
structure with the last list argument. The last argument may actually
be any object; an improper list results if the last argument is not
a proper list.
[1m
(append '(a b) '(c . d))    =>  (a b c . d)
(append '() 'a)             =>  a[m 
-----
*rassq
*rassv
*rassoc
This function is similar the corresponding one named
without the `r', but the a-list is read as [1m(datum . key)[m entries.[m 
-----
*cons*
[1m[SWiT][m Returns the iteration of cons on all its arguments.
[1m
  (cons* 'a 'b '(c . d))  =>  (a b c . d)[m 
-----
*append!
[1m[SWiT][m Destructively appends its arguments. Dangerous -- of course.[m 
-----
*reverse!
[1m[SWiT][m Destructively reverses its argument. Dangerous -- of course.[m 
-----
*list-insert!
[1m[SWiT][m Destructively [4minsert[m the first argument into the list at the given
position. If position = 0, it is equivalent to [1m(cons <obj> <list>)[m.
If the third argument is a predicate, an element of the given list is
search that satisfies the predicate, if such an element is found, the
first argument is inserted just [4mbefore[m that element, otherwise it is inserted
at the end of the list.

Examples:[1m
> (define l '("a" "b" "d"))	=> l
> (list-insert! "e" l 3)	=> '("a" "b" "d" "e")
> (list-insert! "c" l 
    (lambda (x) (string>? x "b")))
				=> ("a" "b" "c" "d" "e")[m 
> (list-insert! "f" l 
    (lambda (x) (string>? x "e")))
				=> ("a" "b" "c" "d" "e" "f")[m 
> l				=> '("a" "b" "c" "d" "e" "f")
-----
*copy-list
[1m[SWiT][m Makes a copy of its argument in the [4mcdr[m direction but not
in the [4mcar[m direction (see also [1mcopy-tree[m and [1mcopy-graph[m).
Equivalent to : [1m(append <list> '())[m.[m 
-----
*acons
[1m[SWiT][m Returns [1m(cons (cons <obj1> <obj2>) <obj3>)[m.
This function is often used to build alists.
[1m
 (acons 'a 'b '((c . d) (e . f)))  =>  ((a . b) (c . d) (e . f))[m 
-----
*copy-graph
[1m[SWiT][m Copy a graph of conses respecting circularities and sharing.[m 
-----
*copy-alist
[1m[SWiT][m Copy an a-list in the cdr direction and its conses [1m(key . datum)[m.[m 
-----
*copy-tree
[1m[SWiT][m Copy a tree of conses. Do not keep sharing. Do not terminate
if there are circularities (see [1mgraph-copy[m).[m 
-----
*subst
[1m[SWiT][m Makes a copy of its last argument (a tree) substituting its first
argument for every subtree that is equal to its second argument.
[1m
(subst 'a '(a b) '((a a b) b a b))  =>  ((a . a) b . a)[m 
-----
*sublis
[1m[SWiT][m Make a copy of its second argument (a tree) with substitutions
performed as in [1msubst[m for each pair taken from its first argument,
an a-list.
[1m
(sublis '(((a b) . a) (b 0)) '((a a b) b a b)) =>  ((a . a) (0) . a)[m 
-----
*remq
*remv
*remove
[1m[SWiT][m Returns a copy of [4<list>[m where all occurrences [1meq?[m (for [1mremq[m),
[1meqv?[m (for [1mremv[m), [1mequal?[m (for [1mremove[m) to the second argument have been removed.[m 
-----
*remq!
*remv!
*remove!
[1m[SWiT][m [1mremq!, remv!, remove![m : destructive versions of [1mremq, remv[m and
[1mremove[m.[m 
-----
*set-mark!
[1m[SWiT][m Mark a cell by an integer. The mark is taken modulo 4,
so its value can only be 0, 1, 2 or 3. Marks are common in graph
algorithms. 
Note: the mark of a cell does not have an external representation.[m 
-----
*get-mark
[1m[SWiT][m Returns the mark of a cell.[m 
-----
			QUADS
*quad?
[1m[SWiT][m Returns [1m#t[m iff its parameter evaluate to a quad.

Quads are a new data type built with four real numbers. Quads can
represent points, vectors in 3D-space and quaternions numbers.

When a point is concerned, the four real numbers are its homogeneous
coordinates (x,y,z,w).

When the last coordinate is zero, it is a 3D-vector. In the language of
projective geometry, it's a point "at infinity" in the direction of
this vector. Points and vectors are used in 4D-space linear
transforms with homogeneous coordinates. A point can be projected on
the 3D-hyperplan w = 1 by dividing its first three coordinates by w
and setting w = 1. It is a well-known mathematical result that any
affine or projective transform in 3D-space can be represented by a
linear transform in 4D-space.

Moreover, quaternions conveniently represent rotations in 3D-space.

Notations: functions that are meaningful for any quad (i.e. a
point at a finite distance, a vector or a quaternion) have names
starting with "quad-". Functions whose most "significant" operand must
be a vector (resp. point, quaternion) have names starting with
"vect3-" (resp. "point-", "quater-").

A quad can also be used to hold four real numbers without having in
mind that it represents any geometric object. In this case, only the
primitives whose name starts with "quad-" should be meaningful.

A vector operand or result will appear in the signature as [4m<vect3>[m, a
point as [4m<point>[m and a quaternion as [4m<quater>[m. Otherwise [4m<quad>[m is
used.

See:
[1mquad[m			[1mquad-equal?[m
[1mquad-ref[m		[1mquad-set![m
[1mquad-copy[m		[1mquad-length[m
[1mquad-scale[m		[1mquad-scale![m
[1mget-qmark[m		[1mset-qmark![m

[1mpoint-distance[m		[1mpoint-line[m
[1mpoint-translate[m	[1mpoint-translate![m
[1mpoint-rotate[m		[1mpoint-rotate![m
[1mpoints->vect3[m

[1mvect3-add[m		[1mvect3-sub[m
[1mvect3-mult[m		[1mvect3-dot[m
[1mvect3-normalize[m	[1mvect3-normalize![m

[1mquater-mult[m		[1mquater-conjugate[m
[1mmake-rotation[m		[1mextern?[m 
-----
*quad
[1m[SWiT][m Make a quad from four real numbers. When only three numbers are
given, it makes a point (the fourth number defaults to 1). When only
two numbers are given, it make a point on the XY plane (i.e. z=0).[m 
-----
*quad-equal?
[1m[SWiT][m Two quads are equal iff they have the same four coordinates.[m 
-----
*quad-ref
[1m[SWiT][m Returns the relevant coordinate, indexed from 0 to 3.[m 
-----
*quad-set!
[1m[SWiT][m Sets the relevant coordinate.[m 
-----
*quad-copy
[1m[SWiT][m Returns a copy of the given quad.[m 
-----
*quad-length
[1m[SWiT][m Returns the [4meuclidian[m length of the four coordinates. When the
quad is a vector, it is the length of the vector; when the quad is a
quaternion, it is its norm (other cases are not geometrically
meaningful).[m 
-----
*quad-scale
[1m[SWiT][m Non destructive version of [1mquad-scale![m (with one quad).[m 
-----
*quad-scale!
[1m[SWiT][m Multiply the four coordinates of each given quad by [4m<real>[m.[m 
-----
*get-qmark
[1m[SWiT][m Mark the given quad by an integer taken modulo 16, so
the mark is between 0 and 15.
Note: As for pairs, there is no external representation of marks.[m 
-----
*set-qmark!
[1m[SWiT][m Returns the mark of a quad.[m 
-----
*point-distance
[1m[SWiT][m Returns the euclidian distance of the two given
points. Equivalent to [1m(quad-length (points->vect3 p1 p2))[m.[m 
-----
*point-translate!
[1m[SWiT][m Destructive version of [1mpoint-translate[m, but performs the
translation on all the points given as arguments.[m 
-----
*point-translate
[1m[SWiT][m Returns a new point, translated from [4m<point>[m by [4m<vect3>[m.[m 
-----
*point-rotate
[1m[SWiT][m Rotate the point with the rotation represented by a quaternion
(consult a mathematician or use the primitive [1mmake-rotation[m).[m 
-----
*point-rotate!
[1m[SWiT][m Destructive version of [1mpoint-rotate[m, possibly on several
points.[m 
-----
*points->vect3
[1m[SWiT][m Returns the vector whose starting point is the first argument
and end point is the second argument.[m 
-----
*point-line
[1m[SWiT][m Returns the point [4mp = (1 - t) * p1 + t * p2 [m where [4mp1[m
is the first argument, [4mp2[m the second and [4mt[m the third.[m 
-----
*vect3-add
[1m[SWiT][m Returns the addition of the two vectors.[m 
-----
*vect3-sub
[1m[SWiT][m Returns the vector substraction of the two vectors.[m 
-----
*vect3-mult
[1m[SWiT][m Returns the vector product of the two vectors.[m 
-----
*vect3-normalize
[1m[SWiT][m Returns a unit vector that is colinear to the given vector.[m 
-----
*vect3-normalize!
[1m[SWiT][m Destructive version of [1mvect3-normalize[m.[m 
-----
*vect3-dot
[1m[SWiT][m Returns the scalar (or `dot') product of the two vectors.[m 
-----
*quater-mult
[1m[SWiT][m Returns the quaternion product of the two given quaternions.[m 
-----
*quater-conjugate
[1m[SWiT][m Returns the conjugate of the given quaternion.[m 
-----
*make-rotation
[1m[SWiT][m Returns a quaternion defining a rotation of angle [4m<real>[m
and direction [4m<vect3>[m.

Note : the result is a unit quaternion only if [4m<vect3>[m is a vector of
length 1.[m 
-----
*extern?
[1m[SWiT][m This function determines in which semi-space a point lies. The
separating plane is defined by a vector and the first given point. The
third argument lies either on the plane or inside one of the two
semi-spaces. [1m#t[m is returned if it's inside the semi-space pointed by
the vector, [1m#f[m if it's inside the other semi-space and [1m()[m if the point
lies on the plane.[m 
-----
			QUEUES
*queue?
[1m[SWiT][m Returns [1m#t[m iff its parameter evaluates to a queue.

Queues are often used data structures that can grow at both ends.
Normally, new elements are inserted at the end, and elements are
fetch from the front. Also called FIFO's. All queues are
mutable. Their external syntax is: [1m#[elt ...][m.

Note: most of the primitive operations on queues can be done in
constant time.

See:
[1mmake-queue[m		[1mqueue[m
[1mqueue-empty?[m		[1mqueue-front[m
[1mqueue-rear[m		[1mqueue-pop![m
[1mqueue-push![m		[1menqueue![m
[1mqueue-copy[m		[1mqueue-rotate![m
[1mqueue-set![m		[1mqueue-length[m
[1mqueue->list[m		[1mqueue->list![m
[1mlist->queue[m		[1mqueue-reverse![m
[1mqueue-insert![m		[1mqueue-append![m
[1mqueue-search[m		[1mdequeue![m 
-----
*make-queue
[1m[SWiT][m Make-queue returns a newly allocated queue of length [4m<exact-int>[m.
If the optionnal argument is given, then all elements of the queue
are initialized to its value, otherwise the contents of the queue
are [1m()[m.[m 
-----
*queue
[1m[SWiT][m Returns a newly allocated queue composed of the arguments.[m 
-----
*queue-empty?
[1m[SWiT][m Returns [1m#t[m iff its parameter evaluates to the
empty queue.

Note: the empty queue is not unique, e.g. [1m(eq? #[] #[]) => #f[m 
-----
*queue-front
[1m[SWiT][m Returns the first element of queue, and raise
[1merror:type[m if the queue was empty.[m 
-----
*queue-rear
[1m[SWiT][m Returns the last element of queue, and raise
[1merror:type[m if the queue was empty.[m 
-----
*queue-pop!
*dequeue!
[1m[SWiT][m [1mqueue-pop![m and [1mdequeue![m are identical. They
retrieve the first element of the queue (that must be a non-empty
queue).[m 
-----
*queue-push!
[1m[SWiT][m Push one or more element(s) at the front of the queue.
Recall that the normal use of a queue is to enter elements at the
end. This function uses the queue as a [4mstack.[m 
-----
*enqueue!
[1m[SWiT][m Push one or more element(s) at the end of the queue.[m 
-----
*queue-copy
[1m[SWiT][m Copy a queue.[m 
-----
*queue-rotate!
[1m[SWiT][m Performs [4m<exact-int>[m rotations on the elements of the
given queue.
[1m
> (queue-rotate! #[a b c] 2) => #[c a b] [m

The default value of [4m<exact-int>[m is 1, if it's negative, an `inverse'
rotation is performed: the last argument is put at the front (and so on).[m 
-----
*queue-length
[1m[SWiT][m Returns the number of elements of [4m<queue>[m.[m 
-----
*queue-ref
[1m[SWiT][m [4m<exact-int>[m must be a valid index of [4m<queue>[m. [1mQueue-ref[m returns the
contents of element [4m<exact-int>[m of [4m<queue>.[m 
-----
*queue-set!
[1m[SWiT][m If the second argument is a number in the queue range,
the corresponding element of the queue is replaced by the third
argument. For example:

[1m> (queue-set! #[a b c] 1 'e) => #[a e c][m. 

If the second argument is a procedure, a search is made in the queue
as in the function [1mqueue-search[m, if an element is found, it
will be replaced by the third argument, otherwise, no assignment is
made.[m 
-----
*queue-insert!
[1m[SWiT][m The elements of the second queue are inserted into the
first one from the given position [4m<exact-int>[m when it is a number. The
second queue2 is also emptied in this process.
[1m
(queue-insert! #[a b c] #[1 2] 1) => #[a 1 2 b c][m

If position is equal to the length of the first queue, the second one
is inserted at the end.

If the third argument is a predicate, the insertion occurs just
before the first found element that satisfies it, or at the end
no such element is found.[m 
-----
*queue-search
[1m[SWiT][m The second parameter is a unary function used as a
predicate. It is applied to each element of the queue until a
non-false result or the end is found, in the first case, the
corresponding element is returned, otherwise [1m#f[m is returned.
[1m
(queue-search #[a b c] (lambda (x) (memq x '(c b)))) =>  b[m 
-----
*queue->list
[1m[SWiT][m A list is created whose elements are those of the queue.
[1m
(queue->list #[a b c])  =>  (a b c) [m 
-----
*queue->list!
[1m[SWiT][m The list whose elements are those of the queue is
returned. Performing destructive operations on this list can destroy
the queue structure.[m 
-----
*list->queue
[1m[SWiT][m Create a queue whose elements are those of the list.[m 
-----
*queue-reverse!
[1m[SWiT][m Desructively reverse the element of the queue.[m 
-----
*queue-append!
[1m[SWiT][m The first queue is appended with the contents of all
subsequent queues, which are emptied in this process. Time is
proportional to the number of arguments (and not to the length of the
queues).[m 
-----
			STRINGS
*string?
Returns [1m#t[m iff its parameter evaluates to a string.

Strings are just arrays of bytes.
Strings are written as sequences of bytes enclosed within doublequotes
(").  A doublequote can be written inside a string only by escaping
it with a backslash (\), as in:

"The word \"recursion\" has many meanings."

A backslash can be written inside a string only by escaping it with
another backslash. A backslash within a string that is not followed by
a doublequote, a backslash or a newline is ignored.

A string constant may continue from one line to the next, a newline
is automatically includes in the string. A backslash followed by
a newline annihilate the newline, so a long line can be written
on several lines without insertion of newlines in the string.

The length of a string is the number of bytes that it contains.  This
number is a non-negative integer that is fixed when the string is
created.  The valid indexes of a string are the exact non-negative
integers less than the length of the string.  The first byte of a
string has index 0, the second has index 1, and so on.

In phrases such as ``the characters of string beginning with
index <start> and ending with index <end>,'' it is understood
that the index <start> is inclusive and the index <end> is
exclusive.  Thus if <start> and <end> are the same index, a null
substring is referred to, and if [4m<start>[m is zero and [4m<end>[m is
the length of [4m<string>[m, then the entire string is referred to.

Some of the procedures that operate on strings ignore the
difference between upper and lower case.  The versions that ignore
case have ``-ci'' (for ``case insensitive'') embedded in their names.

[1m[SWiT][m Notes: 
1) String are implemented as byte arrays, i.e. any byte, including 0, 
   can belong to a string. 
2) Symbol names are immutable. They cannot be taken as arguments to 
   [1mstring-set![m nor [1mstring-fill![m nor [1mstring-blt![m. 
   String literals are immutable objects as required in R[4,5]RS. 
3) Characters that have a name can be ``escaped'' in strings: 
   \n for newline, \t for tab, \b for a backspace, \e for escape, 
   \f for formfeed, and \r for return. 
4) Characters in a string can be also represented by a blackslash 
   followed by three octal digits.
5) A line can be continued with a ``concealed newline'' (i.e a sequence 
   ``backslash-newline'' which will not be part of the string).[m

See:
[1mmake-string[m	[1mstring[m		[1mstring-length[m
[1mstring-ref[m	[1mstring-set![m	[1mstring=?[m
[1mstring-ci=?[m	[1mstring<?[m	[1mstring>?[m
[1mstring<=?[m	[1mstring>=?[m	[1mstring-ci<?[m
[1mstring-ci>?[m	[1mstring-ci<=?[m	[1mstring-ci>=?[m
[1msubstring[m	[1mstring-append[m	[1mstring->list[m
[1mlist->string[m	[1mstring-copy[m	[1mstring-fill![m
[1mstring-match[m	[1mstring-pos[m	[1mstring-blt![m
[1mstring-ref2[m	[1mstring2->list[m	[1mconstant-string?[m 
-----
*make-string
[1mMake-string[m returns a newly allocated string of length [4m<exact-int>[m if
[4m<char>[m is a 8bits-character and [4m2*<exact-int>[m if [4m<char>[m is a
16bits-character.
If [4m<char>[m is given, then all elements of the string are initialized
to [4m<char>[m, otherwise the contents of the [4m<string>[m are spaces.
16bits-characters are included in the string as two consecutive bytes.[m 
-----
*string
Returns a newly allocated string composed of the arguments.
8bits-characters and 16bits-characters can be mixed.[m 
-----
*string-length
Returns the number of bytes in the given [4m<string>[m.[m 
-----
*string-ref
[4m<exact-int>[m must be a valid index of [4m<string>[m.
[1mString-ref[m returns the byte [4m<exact-int>[m of [4m<string>[m using zero-origin
indexing.
[1m[SWiT] exn:range[m is raised if index is not valid.[m 
-----
*constant-string?
[1m[SWiT][m Returns [1m#t[m iff its argument is an immutable string.[m 
-----
*string-ref2
[1m[SWiT][m [4m<exact-int>[m must be a valid index of [4m<string>[m.
[1mString-ref2[m returns the 16bits-character [4m<exact-int>[m of [4m<string>[m using
zero-origin indexing (i.e. the two bytes starting at position [4m<exact-int>[m).
[1mexn:range[m is raised if index is not valid.[m 
-----
*string-set!
[4m<exact-int>[m must be a valid index of [4m<string>[m, and [4m<char>[m must be a
character.
[1mString-set![m stores [4m<char>[m in element [4m<exact-int>[m of [4m<string>[m and
returns [4m<string>[m.
[1m
(define (f) (make-string 3 #\*))
(define (g) "***")
(string-set! (f) 0 #\?)     =>  "?**"
(string-set! (g) 0 #\?)     =>  error
[1m(string-set! (symbol->string 'immutable)
             0
             #\?)           =>  error[m 
-----
*string=?
*string-ci=?
Returns [1m#t[m if the two strings are the same length and contain
the same bytes in the same positions, otherwise returns [1m#f[m.
[1mString-ci=?[m treats upper and lower case letters as though they
were the same character, but [1mstring=?[m treats upper and lower case
as distinct characters.[m 
-----
*string<?
*string>?
*string<=?
*string>=?
*string-ci<?
*string-ci>?
*string-ci<=?
*string-ci>=?
[1mstring<?, string>?, string<=?, string>=?, string-ci<?, string-ci>?,
string-ci<=?, string-ci>=?[m: these procedures are the lexicographic
extensions to strings of the corresponding orderings on 8bits-characters.
For example, [1mstring<?[m is the lexicographic ordering on strings induced
by the ordering [1mchar<?[m 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.[m 
-----
*substring
The second argument, call it ``start'' and the third, call it ``end'',
must satisfy  [1m(<= 0 start end (string-length <string>))[m,
otherwise the exception [1merror:range[m is raised.

[1mSubstring[m returns a newly allocated string formed from the bytes
of [4m<string>[m beginning with index ``start'' (inclusive) and ending with
index ``end'' (exclusive).[m 
-----
*string-append
Returns a newly allocated string whose bytes form the
concatenation of the given strings.[m 
-----
*list->string
[1mList->string[m returns a newly allocated string formed from the
characters in the given list. 8bits-characters and 16bits-characters
can be mixed (and each 16bits-character is treated as two consecutive
8bits-characters).
Note:[1m string->list[m and [1mlist->string[m are inverses so far
as equal? and 8bits-characters are concerned.[m 
-----
*string->list
[1mString->list[1m returns a newly allocated list of the 8bits-characters that
make up the given string. Note: [1mstring->list[m and [1mlist->string[m
are inverses so far as [1mequal?[m and 8bits-characters are concerned.[m 
-----
*string2->list
[1m[SWiT] String2->list[m returns a newly allocated list of the 16bits-characters
that make up the given string. The string must have an even length,
otherwise the exception [1merror:type[m is raised.[m 
-----
*string-copy
Returns a newly allocated copy of the given string.[m 
-----
*string-fill!
Stores [4m<char>[m in every element of the given string and returns
the filled string. When [4m<string>[m is an immutable string an error
is signalled.[m 
-----
*string-match
[1m[SWiT][m The first string is searched into the second starting
from the given position. The first match is returned as the position of
the first argument in the second string. When matching fails, [1m-1[m is 
returned.

Example:[1m
> (string-match "llo" "Hello World" 0)  =>  2[m 
-----
*string-search
[1m[SWiT][m If [4m<char>[m occurs in [4m<string>[m, the first substring of [4m<string>[m
found by searching from position [4m<exact-int>[m and beginning with <char> is
returned, otherwise, the empty string is returned. As with [1mstring-match[m,
the result shares its characters with the argument [4m<string>[m.

Example:[1m
> (string-search "Hello World" #\space 0)  =>  " World"[m 
-----
*string-pos
[1m[SWiT][m Returns the position in [4m<string>[m of the first occurrence of
[4m<char>[m. The search starts from position [4m<num>[m. If [4m<char>[m is not found,
-1 is returned.

Examples:[1m
> (let ((str "Hello World"))
    (substring str (+ 1 (string-pos str #\space 0)) (string-length str)))
=> "World"
> (let ((str "Hello_World"))
    (substring str (+ 1 (string-pos str #\space 0)) (string-length str)))
=> "Hello_World"[m 
-----
*string-blt!
[1m[SWiT][m ``blt'' is a short for ``block transfer'' : the second string
is displaced onto the first string starting at position [4m<exact-int>[m. If
the second string is too long to fit into the first, only a prefix is
displaced. If [4m<exact-int>[m is greater than the length of the first string
nothing is done. [1mstring-blt![m returns the first (and probably
modified) string.

Example:[1m
> (string-blt! (make-string 7 #\a) 3 "bb") => "aaabbaa"
[m

Note : the first string must be mutable, the second need not.[m 
-----
*primitive->string
[1m[SWiT][m The name of the primitive is returned (without the leading #').[m 
-----
			SOCKETS
*socket?
[1m[SWiT][m Returns [1m#t[m iff its parameter evaluates to a
socket.[m

See:
[1msocket-portnum[m			[1msocket-port[m
[1msocket-port?[m			[1msocket-host[m
[1mmake-server[m			[1maccept[m
[1mmake-client[m			[1mservice->portnum[m
[1mportnum->service[m		[1maddr->hostname[m
[1mhostname->addr[m
-----
*socket-portnum
[1m[SWiT][m Returns the port number that [4m<socket>[m is listening to.
This `port' should not to be confused with the Scheme object 
[1msocket-port[m.[m 
-----
*socket-port
[1m[SWiT][m Returns the [4mScheme[m port associated to [4m<socket>[m.[m 
-----
*socket-port?
[1m[SWiT][m Returns [1m#t[m iff its parameter evaluates to a
port that is associated to a socket.[m 
-----
*socket-host
[1m[SWiT][m Returns the hostname associated to [4m<socket>[m. If
[4m<socket>[m is a [4mclient[m socket, the hostname is always the peer hostname,
if [4m<socket>[m is a [4mserver[m socket, hostname is always "localhost".[m 
-----
*make-server
[1m[SWiT][m Given a port number (that should not be already in use),
returns a server socket ready to accept connections. Some examples of
elementary client/server applications are given in the library demos.[m 
-----
*accept
[1m[SWiT][m Called by a server to accept connections from
clients. The argument is a ``server'' socket. Returns a new socket to
establish the two-ways connection between the server host and the
client host.
The hostname of the client is stored in the result and can be
retreived with [1msocket-host[m. Warning: no identification means is
implemented and any process can connect with such a server.[m 
-----
*make-client
[1m[SWiT][m Called to request a connection with a host whose name is
[4m<string>[m on which a server is listening on port number
[4m<exact-int>[m. Returns a socket whose port can be used with all
standard I/O primitives (such as [1mread[m, [1mwrite[m, etc.)
as soon as the connection has been accepted on the server side.[m 
-----
*service->portnum
[1m[SWiT][m Returns the port number associated to the service. If
the service is unknown, 0 is returned.[m 
-----
*portnum->service
[1m[SWiT][m Returns the name of the service associated to a port
number:[1m

> (portnum->service 80)
"http"[m 
-----
*addr->hostname
[1m[SWiT][m May not work...[m 
-----
*hostname->addr
[1m[SWiT][m Returns the internet address associated to a given
hostname or the null string if the hostname is not known.
[1m
> (hostname->addr "localhost")
"127.0.0.1"[m 
-----
			TK IN SWIT
*tk-eval
*tk-cmd
[1m[SWiT][m  [1mtk-eval[m and [1mtk-cmd[m are the two main
commands to execute the Tcl/Tk script [4m<string>[m. They differ only by
the result: the fisrt one returns the Tcl/Tk result as a string, the
second one ignores it and always returns [1m#t[m. If the script
raises a Tcl/Tk error, [1m#f[m is returned after a call to tkerror,
otherwise, the Tcl string result is returned.
[1m
> (tk-eval "exec ls -l")
"total 1415
-rw-r--r--   1 didier   users        1327 Nov  6 02:40 Makefile
drwxr-xr-x   2 didier   users        1024 Nov  9 12:18 doc
[m etc.[1m"

> (tk-cmd "source /usr/lib/tk4.1/demos/widget")
[m
(and you can play with the widget demos ...)

Generally, the ``tk parts'' and the ``scheme parts'' of a swit
program are written in a separate files, and most of the time the
tk-eval command is used to ``source'' the tk files.

Note: Tcl is a powerful scripting language and many functions on
strings that are not implemented in Scheme are available in Tcl. E.g.
globing, regular expression, etc. See a Tcl documentation or Tcl/Tk man
pages and learn some Tcl programming... For example, globing can be
acheived with the following command:
[1m
> (split-string (tk-eval "eval {exec ls} [glob src/*.swt]") #\newline)
("src/compile.swt" "src/debug.swt" "src/disassemble.swt" "src/doc.swt" "src/macros-r5rs.swt" "src/macros.swt" "src/macrosr4.swt" "src/objects.swt" "src/pptype.swt" "src/sig.swt" "src/strings.swt" "src/test.swt" "src/type.swt" "src/unif.swt")[m 
-----
*tk-source
[1m[SWiT][m Better than a [1m(tk-eval "source filename")[m because it
takes into account the environment variable [1mSWIT_LIBRARY_PATH[m when a
relative filename is given to it.

Conversely, scheme expressions or programs can be evaluated from a
Tcl script with the following Tcl commands:
[1m
swit-expr <arg1> [<arg2>]
swit-call <arg1> <arg2> ...
swit-val <arg>[m

The first of these commands is the most general one. Its first
argument is any scheme expression or program. Its second argument
is optional and will be parsed as a symbol whose value mut be is a
(scheme) environment. When an environment is given, the expression is
evaluated in that environment (in this case define and defmacro
expressions are not allowed). When no environment is given, the global
environment is taken as the default. The two next commands are
restrictive forms of the first one, but they are 2 or 3 times faster
than the equivalent command written with [1mswit-expr[m.

[1mswit-call[m takes any number of arguments,
the first one must name of function (not a macro) and the
others are its arguments. They are (Tcl) strings that will be parsed
as scheme datum or symbols. Warning (bug): a variable-arity
function, say fun, with no argument must be called as
[1mswit-call apply fun nil[m.

[1mswit-val[m takes one argument, parsed as a symbol, and returns the
value of this symbol in the global scheme environment.

When the result is a list, it will be returned (to Tcl) with the Tcl
printing conventions for lists (see the Tcl documentation).
[1m
> (define x 1)
> (tk-eval "swit-val x")  =>  "1"
> (tk-eval "swit-expr {(set! x 10)}")  =>  "10"
> x  =>  10
> (tk-eval "swit-call fact x")  =>  "3628800"
> (tk-eval "swit-call car {((a (b c)) d)}")  =>  "a {b c}"[m 
-----
*ring-bell
[1m[SWiT][m Rings the current bell.[m 
-----
*init-bell
[1m[SWiT][m Returns the current (percent, pitch, duration) of the
bell.[m 
-----
*set-bell!
[1m[SWiT][m Sets a new pitch.[m 
-----
*play-note
[1m[SWiT][m Play a note whose pitch is defined by its first argument
and duration by the second argument.[m 
-----
			SYMBOLS
*symbol?
Returns [1m#t[m if its parameter evaluates to a symbol, otherwise returns [1m#f[m.
[1m
(symbol? 'foo)              =>  #t
(symbol? (car '(a b)))      =>  #t
(symbol? "bar")             =>  #f
(symbol? 'nil)              =>  #t
(symbol? '())               =>  #f
(symbol? #f)                =>  #f[m

Symbols are objects whose usefulness rests on the fact that two symbols
are identical (in the sense of [1meq?[m) if and only if their
names are spelled the same way.  This is exactly the property needed to
represent identifiers in programs, and so Scheme use them internally
for that purpose.  Symbols are useful for many other applications; for
instance, they may be used the way enumerated values are used in Pascal.

The rules for writing a symbol are exactly the same as the rules for
writing an identifier.

It is guaranteed that any symbol that has been returned as part of
a literal expression, or read using the `[1mread[m' procedure, and
subsequently written out using the write procedure, will read
back in as the identical symbol (in the sense of [1meq?[m).[m

See:
[1msymbol->string[m			[1mstring->symbol[m
[1mkeyword?[m			[1mgentemp?[m
[1mgentemp[m				[1msymbol-value[m
[1munbound-object?[m		[1mset-symbol![m
[1mhash-table-stats[m		[1mapropos[m 
-----
*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 lower case. If the symbol was returned by [1mstring->symbol[m,
the case of characters in the string returned will be the same as the
case in the string that was passed to [1mstring->symbol[m. It is an
error to apply mutation procedures like [1mstring-set![m to strings
returned by this procedure (exception [1merror:type[m is raised in
that case).
[1m
(symbol->string 'flying-fish)
                            =>  "flying-fish"
(symbol->string 'Martin)    =>  "martin"
(symbol->string
   (string->symbol "Malvina"))
                            =>  "Malvina"[m 
-----
*string->symbol
Returns the symbol whose name is string. 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 [1msymbol->string[m.
[1m
(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[m 
-----
*keyword?
[1m[SWiT][m Returns [1m#t[m iff [4m<symbol>[m is a keyword.
The keywords are:

[1m=>[m		[1mdo[m		[1mor[m
[1mand[m		[1melse[m		[1mquasiquote[m
[1mbegin[m		[1mif[m		[1mquote[m
[1mcase[m		[1mlambda[m		[1mset![m
[1mcond[m		[1mlet[m		[1munquote[m
[1mdefine[m		[1mlet*[m		[1munquote-splicing[m
[1mdelay[m		[1mletrec[m		[1mdefmacro[m
[1mtry[m		[1mstep-eval[m	[1mdeclare[m
[1msignature[m	[1mdefclass[m

E.g.
[1m(keyword? 'let)  =>  #t[m

Note: The boolean global variable *keywords* is used by the
compiler. When [1m#f[m (the default), keywords can be used as
variables.[m 
-----
*gentemp
[1m[SWiT][m Creates a new (interned) symbol whose name is [4m<string>[m
concatenated with an integer. [4m<string>[m is always converted to lower
case. The default prefix is [1mg:[m.[m 
-----
*gentemp?
[1m[SWiT][m Returns [1m#t[m iff [4m<symbol>[m was created with
[1mgentemp[m.[m 
-----
*symbol-value
[1m[SWiT][m Returns the value of [4m<symbol>[m in [4m<env>[m (or in the global
environment when [4m<env>[m is not given). When the [4m<symbol>[m is unbound, an
error is not raised, but the unbound object is returned.[m 
-----
*set-symbol!
[1m[SWiT][m Assigns [4m<symbol>[m to the value of its second parameter in
the given environment [4m<env>[m, or in the global environment if the
optional argument is not given.

Note : The value can be any value; in particular, if it's
[1m##unbound[m, [4m<symbol>[m will be become ``unassigned''.[m 
-----
*unbound-object?
[1m[SWiT][m Returns [1m#t[m iff the value of its parameter is the
unbound object.

Note: the unbound object has an external syntax: [1m##unbound[m.[m 
-----
*hash-table-stats
[1m[SWiT][m Returns info about the contents of the symbol
hash-table, the total number of defined symbols and other very
essential informations...[m 
-----
*check-signatures
[1m[SWiT][m Returns the list of primitives that have no defined
signatures (and consequently, cannot be used with typing enabled).[m 
-----
*get-prim
[1m[SWiT][m UNDOCUMENTED (for internal use only).[m 
-----
*apropos
[1m[SWiT][m Returns the list of all defined symbols for which
[4m<string>[m is a substring. The list of all symbols can be obtained
with [1m(apropos "")[m. It is probably not a good idea try the
next example...
[1m
> (for-each (lambda (s) (set! (symbol-value s) ##unbound)) (apropos ""))
       =>  #t[m 
-----
*oblist
[1m[SWiT][m Returns the list of all bound symbols.[m 
-----
*putprop!
[1m[SWiT][m Add a value (the third argument) into the property list
of the first symbol associated to a key, the second symbol. If the key
already exists in the property list, its associated value is
overwritten. The new value is returned.[m 
-----
*getprop
[1m[SWiT][m Get the value associated to the key (the second
argument) in the property list of the first argument. If the key is
not found, the unbound object is returned.[m 
-----
*remprop!
[1m[SWiT][m The property list of the first argument is search with
the second argument as the key. The corresponding property, if found,
is removed and [1m#t[m is returned. Otherwise, [1m#f[m is
returned.[m 
-----
*symbol-plist
[1m[SWiT][m Returns a [4mcopy[m of the property list of [4m<symbol>[m
as an a-list.[m 
-----
*help
[1m[SWiT][m [1mHelp[m provides in-line help about all primitives
and programming constructs implemented in SWiT. Apart for primitives
or new keywords specific to SWiT, this documentation is taken from
``Revised^4 Report on the Algorithmic Language Scheme''.

E.g. [1m(help string-blt!)[m will display on the terminal the
signature of the primitive [1mstring-blt![m followed by a short text
explaining how to use it. Sometimes, examples are also given.

To get information about program structures, type [1m(help '[m<a keyword>[1m)[m 
(don't forget the [4mquote[m in this case). The list of all keywords can
be seen with [1m(help [1mkeyword?[m)[m.

General information about a data type can be found with the predicate
associated to it. E.g. type [1m(help vector?)[m to know how to use
vectors. Here are the general (i.e. they can be applied to any object)
predicates defining the disjoint data types of SWiT:

[1mboolean?[m			[1mvector?[m
[1mchar?[m				[1mprocedure?[m
[1msymbol?[m				[1mpromise?[m
[1mstring?[m				[1mqueue?[m
[1mpair?[m				[1mquad?[m
[1mnumber?[m				[1mturtle?[m
[1mport?[m				[1msocket?[m
[1meof-object?[m			[1munbound-object?[m
[1menvironment?[m			[1mbezier?[m
[1mnull?[m

Some documentations of primitives provide more information than just
about the use of the primitive itself. E.g. [1meq?[m and [1meqv?[m
give thorough information about equality, [1mread[m gives much
information about the syntax of Scheme. 

Other general entries are:
[1mschelog[m for the documentation about Dorai Sitaram's implementation
of logic programming in Scheme (file `schelog.scm').
[1mdebug[m for the debugging tools defined in the file `debug.swt'.
[1mtype[m for the typing system.

[1mhelp[m also display the documentation string of a symbol.
[1m
(define (sqr x) 
 "Function \e[1m(sqr x)\e[m: returns the square of the number x" 
 (* x x))
  => sqr
(help 'sqr)
Function [1m(sqr x)[1m: returns the square of the number x
  => #t[m 

The scheme-defined function [1mhelpx[m can be given one or
more arguments and opens a window that displays all the asked
documentation. Moreover, when [1mhelpx[m finds an argument
that is a string, it replaces it with the list of all primitives
whose name have that string as a substring. E.g: [1m(helpx "tk")[m
will display the documentations of the three primitives [1mtk-eval[m,
[1mtk-cmd[m and [1mtk-source[m.[m 
-----
*set-help!
[1m[SWiT][m Add a documentation string to [4m<symbol>[m. The
documentation string is usually given when the symbol is defined
(see [1mdefine[m).[m 
-----
*get-code
[1m[SWiT][m Returns the source code of a function.[m 
-----
			TYPE
*type-of
[1m[SWiT][m This function gives a coarse result, e.g. a procedure
will be a `<closure>', a `<primitive>'  or a `<continuation>'.
A more detailled information about the type of an expression is given
with the type inference system (if the variable [1m*type*[m is set to [1m#t[m).
A type error does not prevent to evaluate the ill-typed expression:
numerous expressions in Scheme cannot receive a type but a trivial
one. On the other hand, expressions that are written in a
`good' functional style should be typed [4m la ML[m and this information
can be useful to the programmer.

Here is a short sample session:
[1m
> (define (factorial n) (if (zero? n) 1 (* n (factorial (- n 1)))))
factorial : <num> -> <num>
> (define (app l1 l2) (if (null? l1) l2 (cons (car l1) (app (cdr l1) l2))))
app : <pair> * <pair> -> <pair>
> (app '(a b) '(c d))
(a b c d) : <symbol> list
> (app '(1 a) '(c))
(1 a c) : <pair>[m 
-----
*get-signature
[1m[SWiT][m Returns the signature of the given primitive (in an
internal form).[m 
-----
*set-signature!
[1m[SWiT][m Define the signature of a primitive. This primitive 
should only be used in the file [1msig.swt[m.[m 
-----
*type?
[1m[SWiT][m Returns [1m#t[m iff <symbol> is a ``type''. Some
symbols are defined at initialisation and are ``tagged'' as
types: [1m<number>, <fixnum>, <bignum>, <string>, <vector>, <symbol>,
<bool>, <char>, <ratio>, <complex>, <procedure>, <port>, <queue>,
<env>, <turtle>, <quad>.[m 
-----
			VECTORS
*vector?
Returns [1m#t[m if its parameter evaluates to a vector, otherwise returns [1m#f[m.

Vectors are heterogenous structures whose elements are indexed
by integers.  A vector typically occupies less space than a list
of the same length, and the average time required to access a randomly
chosen element is typically less for the vector than for the list.

The length of a vector is the number of elements that it contains.
This number is a non-negative integer that is fixed when the vector
is created.  The valid indexes of a vector are the exact non-negative
integers less than the length of the vector.  The first element in
a vector is indexed by zero, and the last element is indexed by one
less than the length of the vector.

Vectors are written using the notation [1m#(<obj> ...)[m.
For example, a vector of length 3 containing the number zero in
element 0, the list [1m(2 2 2 2)[m in element 1, and the string [1m"Anna"[m
in element 2 can be written as following:
[1m
#(0 (2 2 2 2) "Anna")[m

Note that this is the external representation of a vector, not an
expression evaluating to a vector.  Like list constants, vector
constants must be quoted:
[1m
'#(0 (2 2 2 2) "Anna")
          =>  #(0 (2 2 2 2) "Anna")[m

See:
[1mmake-vector[m		[1mvector-ref[m
[1mvector[m			[1mvector-length[m
[1mvector-set![m		[1mvector->list[m
[1mlist->vector[m		[1mvector-fill![m
[1mvector-append[m		[1mvector-copy[m
[1mvector-reverse![m	[1mvector-sort![m
[1mbinary-search[m		[1mget-vmark[m
[1mset-vmark![m		[1msubvector[m 
-----
*make-vector
Returns a newly allocated vector of [4m<exact-int>[m elements. If a second
argument is given, then each element is initialized to its
value. Otherwise the initial contents of each element is [1m()[m.[m 
-----
*vector
Returns a newly allocated vector whose elements contain the given
arguments. Analogous to list.[m 
-----
*vector-length
Returns the number of elements in [4mvector[m.[m 
-----
*vector-ref
[4m<exact-int>[m must be a valid index of [4mvector[m. [1mVector-ref[m returns the
contents of element [4m<exact-int>[m of [4mvector[m.
[1m
(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[m 
-----
*vector-set!
[4m<exact-int>[m must be a valid index of vector. [1mVector-set![m stores
the value of the second parameter in element [4m<exact-int>[m of
vector. The value returned by [1mvector-set![m is the stored value.
[1m
(let ((vec (vector 0 '(2 2 2 2) "Anna")))
  (vector-set! vec 1 '("Sue" "Sue"))
  vec)
          =>  ("Sue" "Sue")

(vector-set! '#(0 1 2) 1 "doe")
          =>  error  ; constant vector[m 
-----
*vector->list
*list->vector
[1mVector->list[m returns a newly allocated list of the objects
contained in the elements of vector. [1mList->vector[m returns a newly
created vector initialized to the elements of the given list.[m 
-----
*vector-fill!
Stores the value of its second parameter in every element of
<vector>. The value returned by [1mvector-fill![m is the (filled) vector.[m 
-----
*vector-blt!
[1m[SWiT][m This a vector ``block transfer''. Similar to [1mstring-blt![m.[m 
-----
*subvector
[1m[SWiT][m Similar to [1msubstring.[m 
-----
*vector-reverse!
[1m[SWiT][m Destructively reverse the elements of the given vector.[m 
-----
*vector-copy
[1m[SWiT][m Equivalent to [1mvector-append[m called with one
argument.[m 
-----
*vector-append
[1m[SWiT][m Copy all its arguments, including the first one, into a
newly allocated vector.[m 
-----
*binary-search
[1m[SWiT][m Search the first argument into the given vector using
the ``comparison function''.
The ``comparison function'' has the same caracteristics as for [1mvector-sort![m and the vector should be already ordered with respect to it. Usually, the first argument is a key to be searched into the vector.
An element of the vector equal with respect to the
comparison function is returned if found, otherwise the returned value
is #f.
[1m
> (define v (vector '(4 a) '(7 k) '(5 e) '(1 r)))  =>  v
> (vector-sort! v (lambda (x y) (- (car x) (car y))))
       =>  #((1 r) (4 a) (5 e) (7 k))
> (binary-search 4 v (lambda (x y) (- x (car y))))  =>  (4 a)[m 
-----
*vector-sort!
[1m[SWiT][m Destructively sort a vector.
The first parameter must evaluates to a ``comparison function''
returning 0 if its arguments are equal, a positive integer if the
first is the greatest and a negative integer otherwise. This function
serves to compare elements of the first parameter. The vector is
destructively sorted in ascending order with respect to the comparison
function, and is returned (see also [1mbinary-search[m).
[1m
> (vector-sort! #(5 9 7 8 -9 8 1 3) -)  =>  #(-9 1 3 5 7 8 8 9)[m 
-----
*set-vmark!
[1m[SWiT][m Mark a vector by an integer taken modulo 256,
so the mark is indeed between 0 and 255.
Note: marks have no external representation.[m 
-----
*get-vmark
[1m[SWiT][m Returns the mark of a vector.[m 
-----
*schelog
   Schelog implements Prolog-style backtracking using Scheme's
first-class continuations.  Backtracking solves a problem or [4mgoal[m by
trying to solve its [4msubgoals[m.  If a goal is a simple or [4matomic[m
goal, it is solved by matching it with statements or [4mfacts[m in a
database.  A goal that is solved is said to succeed.  Alternatively, a
goal that succeeds is said to be true.  A goal that fails is said to be
false.  A successful goal may be retried to see if it succeeds in
another way -- this process may be continued till it ultimately fails.

   A common way of constructing goals is by applying [4mpredicates[m to
objects.  These objects may be simple stuff like numbers, characters,
etc., or composite structures based on them, like lists, vectors,
strings, etc.  As we shall see later, Schelog objects can be pretty
much anything you can conceive of -- including operators like Scheme
procedures, Schelog predicates and Schelog goals.  But first, let's
look at logic variables, which build the edifice of Schelog.

   A logic variable is a mutable binding of a cell to an object.  As
expected, a logic variable is also a Schelog object.  (Note: Logic
variables may be bound to other logic variables.  As a particular case,
a logic variable bound to itself is deemed to be an [4munbound[m logic
variable.)  For ways of introducing logic variables see below [4mSchelog logic variables[m.

   In the Schelog embedding, Scheme objects do duty for Prolog objects.
The only complication is logic variables, so some extra machinery is
needed to reference and dereference the cells of logic variables when
viewing Scheme objects as Schelog objects.


[4mSchelog goals and predicates[m

 - Syntax: [1mrel LOCAL-LOGIC-VARIABLES CLAUSE ...[m
     Used for making predicates and goals.  An example of a goal is the
     Schelog ([4mand[m Scheme) expression:
[1m
          (%member x '(1 2 3))
[m
     Here [1m%member[m is a predicate, x is a logic variable and [1m'(1 2 3)[m is
     a structure -- the whole expression is a goal.  Given the suitably
     intuitive definition of %member, the above goal succeeds if the
     binding of [1mx[m is 1, or 2, or 3.

     Now to defining predicates like [1m%member[m.  Schelog's Prolog syntax
     uses Scheme s-expressions, and as such, may need some getting used
     to.  For example, the member predicate in "real" Prolog reads:
[1m
          member(X, [X|Xs]).
          member(X, [Y|Ys]) :- member(X, Ys).
[m
     The same program in Schelog reads:
[1m
          (define %member
            (rel (x xs y ys)
              [(x (cons x xs))]
              [(x (cons y ys)) (%member x ys)]))
[m
     I.e., [1m%member[m is defined as a relation, which is specified using
     the "rel" macro.  rel's first subexpression lists all the logic
     variables local to itself.  (Real Prolog doesn't bother specifying
     this, since it uses a capitalization convention to distinguish
     logic variables from everything else, and has no notion of
     lexically hiding logic variables.  In contrast, Schelog, in the
     spirit of Scheme, does not enforce a naming convention, and also
     does not force logic variables to have global names.)

     rel's subsequent subforms are clauses describing the relation.  In
     this case, the first clause of [1m%member[m:
[1m
          [(x (cons x xs))]
[m
     states that (%member x (cons x xs)) is a goal that will always
     succeed.  I.e., if %member's first and second arguments can be
     unified with x and (cons x xs) respectively, the first argument is
     a member of the second.  The second clause of %member:
[1m
          [(x (cons y ys)) (%member x ys)]
[m
     states that [1m(%member x (cons y ys))[m is true if x is a member of ys.

     Here are some [4matomic[m goals, which are much simpler than [1m(%member
     1 '(1 2 3))[m: The Schelog goal [1m%true[m is defined so that it succeeds
     once; the Schelog goal [1m%fail[m always fails.

     Note that I have used a convention here of naming Schelog
     predicates with an initial %.  This is purely for convenience --
     in particular, I wanted to avoid clashes with Scheme procedure
     names (there is already a Scheme procedure called member).  Note,
     however, that this % convention is not mandatory [[4munlike[m Prolog's
     initial capital for variables].  You may flout the % convention or
     replace it with one that is more pleasing to you.

     Note also that Scheme's cons takes the place of Prolog's |.  In
     general, Scheme's data structures can be used without change in
     Schelog.  In particular, each of the following Scheme expressions:

         [1m '(1 2 3)  ;with the quote
          
          (list 1 2 3)
          
          (cons 1 (cons 2 (cons 3 '())))
          
          (cons x (list y z)) ;where x, y, z are Scheme (lexical
                              ;or global) variables bound to 1, 2, 3
[m
     may be used for Prolog's
[1m
          [1, 2, 3]
[m
 - Procedure: [1m_[m
     Prolog users will have noted that the variables y and ys in the
     definition of %member needn't have names, since they are never
     needed beyond their single occurrence in the %member code.
     Schelog, like Prolog, lets you use anonymous variables.  Where
     Prolog uses [1m_[m, Schelog uses [1m(_)[m.  (I.e., [1m_[m is a thunk that
     generates an anonymous variable.)  The [1m%member[m predicate can be
     rewritten as:
[1m
          (define %member
            (rel (x xs)
              [(x (cons x (_)))]
              [(x (cons (_) xs)) (%member x xs)]))
[m
[4mSchelog queries[m

 - Syntax: [1mwhich QUERIED-LOGIC-VARIABLES GOAL[m
     The interactive Prolog queries (?-) are handled in Schelog through
     the form "which".  Type a which-query just as you would any Scheme
     expression that you'd want to evaluate, i.e., at the Scheme
     prompt.  The first subform of which is a list of the variables
     whose bindings you want -- make it nil if you simply want a yes/no
     answer.  Thus,
[1m
          (which () (%member 1 '(1 2 3)))
[m
     corresponds to
[1m
          ?- member(1, [1, 2, 3])
[m
     and returns

         [1m ()[m

     This means that the goal succeeded, but since no variables were
     requested  in the answer, you get an empty list.  To get more
     solutions, use "more".

 - Procedure: [1mmore[m
     Typing

        [1m  (more)[m

     is like saying "yes" to Prolog's "more?" prompt.  Here, for
     instance, typing [1m(more)[m gives you [1m#f[m -- falsity signifying that
     there are no alternate solutions to this goal.

     N.B.: In this case, the distinction between falsity and truth for
     a query with no variables depends on Scheme's distinguishing
     between [1m#f[m and [1m()[m.   Thus, the query, as stated above, is useless
     in Scheme dialects where [1m#f[m and [1m()[m are identical.  Mercifully,
     this is easily remedied -- simply use a dummy variable in the
     which-query: Truth will give an (ignorable) binding for the dummy
     variable, while falsity will give [1m#f[m.

     For another example, consider the query

        [1m  (which (x) (%member x '(1 2 3)))[m

     Here you want an instantiations for [1mx[m that satisfy the goal
     [1m(%member x '(1 2 3))[m.  Sure enough, the result of this is

         [1m ([x 1])[m

     viz., a list containing the logic variable bindings requested.
     Here only one variable (i.e., x) was requested, so the result is a
     singleton list containing x's binding.  A binding consists of the
     variable's name and its value, e.g., [1m[x 1][m.

     Typing (more gives more solutions.  To continue with the above
     example:
[1m
          > (more)
          ([x 2])
          
          > (more)
          ([x 3])
          
          > (more)
          #f
[m
     The final [1m#f[m shows that there are no more solutions.

     One could also have queries of the form
[1m
          > (letref (x ...) (which (y ...) query))
[m
     Both letref (see [4mSchelog logic variables[m) and which
     introduce local logic variables (much like Scheme's let).
     However, in the solutions, only the which-variables are
     enumerated.  E.g.,
[1m
          > (letref (x) (which () (%member x '(1 2 3))))
[m
     succeeds three times, without giving the values of x.
[1m
          > (letref (x) (which () (%member x '(1 2 3))))
          ()
          > (more)
          ()
          > (more)
          ()
          > (more)
          ()
          > (more)
          #f
[m
4mSchelog cutm

 - Procedure: [1m![m
     The cut is written [1m![m, as in Prolog.  For example, the if-then-else
     predicate, which is written in "real" Prolog as:
[1m
          if_then_else(P, Q, R) :- P, !, Q.
          if_then_else(P, Q, R) :- R.
[m
     has the following look in Schelog:
[1m
          (define %if-then-else
            (rel (p q r)
              [(p q r) p ! q]
              [(p q r) r]))
[m
     One of the most common use of [1m![m is to implement negation:
[1m
          (define %not
            (rel ()
              [(g) g ! %fail]
              [(g) %true]))
[m

   Note:  People used to first-class this and first-class that wouldn't
have batted an eyelid over the fact that in both the above examples, the
predicate's arguments range over goals.


[4mSchelog logic variables[m

   As noted, rel's first subform introduces the set of logic variables
local to the relation's definition.  Similarly, which's first subform
introduces the logic variables whose bindings are to be examined.  Logic
variables are important in Prolog.

   In general, logic variables can be made with the thunk [1m_[m, the same
procedure used for generating anonymous variables.  Thus

    [1m (define lv (_))[m

   makes the Scheme identifier [1mlv[m refer to a new unbound logic variable.

 - Syntax: [1mletref (IDENT ...) BODY[m
     Local logic variables can be introduced through Scheme's various
     lexical-scoping mechanisms.  For convenience, the form letref is
     provided, where
[1m
          (letref (x ...) body)
               expands to
          (let ([x (_)] ...) body)
[m
     I.e., [1mx, ...[m refer to new logic variables that can be used by
     body.  (The macros rel and which both rely on letref to introduce
     logic variables.)

     Note that the logic variable is a Scheme object of infinite extent
     (modulo gc and session termination).

[4mSchelog unification[m

 - Procedure: [1m== OBJ1 OBJ2[m
     The predicate [1m==[m embodies Schelog's unification mechanism.  Thus
     [1m(== x y)[m is a goal that succeeds if [1mx[m can be unified with [1my[m.  For
     example, the query

         [1m (which (x) (== (list 1 2) (list x 2)))[m

     succeeds with answer

         [1m ([x 1])[m


[4mSchelog conjunctions and disjunctions[m

   Goals may be combined using the forms %or and %and to form compound
goals.  E.g.,

 - Syntax: [1m%and GOAL ...
          (which (x)
            (%and (%member x '(1 2 3)) (%lt x 3)))[m

     requests solutions for x that satisfies both the subgoals: i.e., x
     should be a member of '(1 2 3) [4mand[m x should be less than 3.
     (%lt is a primitive predicate supplied with Schelog.)  The first
     solution is

          [1m([x 1])[m

     Typing (more) gives another solution:

         [1m ([x 2])[m

     and that's it (because [1m[x 3][m satisfies the first but not the
     second goal).

 - Syntax: [1m%or GOAL ...[m
     Similary the query
[1m
          (which (x)
            (%or (%member x '(1 2 3)) (%member x '(3 4 5))))
[m
     lists all [1mx[m that are members of either list.
[1m
          ([x 1])
          ([x 2])
          ([x 3])
          ([x 3])
          ([x 4])
          ([x 5])
[m
     (Yes, [1m([x 3])[m is listed twice.)

[4mSchelog arithmetic[m

 - Syntax: [1m%is OBJ OBJ[m
     The goal [1m(%is x y)[m succeeds if [1mx[m can be unified with the
     arithmetic (in fact, any Scheme) expression [1my[m.  Note that [1m%is[m is
     not just an abbreviation for [1m==[m (Schelog unification),
     since the expression need not be a Schelog value or structure.  An
     example will make this clear:
[1m
          (which (x y)
            (%and (%is x 2)
          	  (%is y (+ x x))))[m

     succeeds with [1m[x 2][m and [1m[y 4][m.  If the [1m%is[m's had been [1m==[m's, the
     first subgoal [1m(== x 2)[m would indeed bind [1mx[m to [1m2[m.  But the second
     subgoal [1m(== y (+ x x))[m would result in an error, because Scheme
     would try to add two non-numbers.

   Other arithmetic goals provided with Schelog are: [1m%eq[m, %gt[m, %ge[m,
[1m%lt[m, [1m%le[m, [1m%ne[m (abbreviations for equals, greater than, etc.)  The usage
is:

     [1m(%eq x y)[m

   succeeds if [1mx[m and [1my[m can be unified to the same number.  Similarly
for the other predicates.

[4mSchelog types[m

 - Procedure: [1m%var OBJ[m
     The goal [1m(%var x) succeeds if [1mx[m is a structure that hasn't been
     completely bound -- i.e., it has at least one logic variable in
     its innards that is unbound.

 - Procedure: [1m%nonvar OBJ[m
     [1m%var[m's negation is %nonvar[m.

 - Procedure: [1m%constant OBJ[m
     [1m%constant[m tests if its argument is a non-composite object.

 - Procedure: [1m%compound OBJ[m
     [1m%constant[m's negation is [1m%compound[m.


[4mOther Schelog predicates[m

 - Procedure: [1m%ident OBJ OBJ[m
     [1m(%ident x y)[m tests if [1mx[m and [1my[m are identical objects.  This is not
     quite [1m==[m, for it doesn't touch unbound objects the way [1m==[m does.
     E.g., [1m%ident[m will not equate two unbound logic variables, unless
     they happen to be the [4midentical[m logic variable.

 - Procedure: [1m%nonident OBJ OBJ[m
     The negation of [1m%ident[m is [1m%nonident[m.

   Variables are generally difficult to treat as other objects, because
they get unified at the merest mention.  To avoid this, the predicates
[1m%freeze[m, [1m%melt[m, [1m%melt-new[m, and [1m%copy[m are provided.

 - Procedure: [1m%freeze OBJ OBJ[m
     [1m(%freeze s f)[m unifies [1mf[m to the frozen version of [1ms[m -- i.e., any
     lack of bindings in [1ms[m are preserved no matter how much you toss [1mf[m
     about.

 - Procedure: [1m%melt OBJ OBJ[m
     [1m(%melt f s)[m retrieves the structure frozen in [1mf[m into s.

 - Procedure: [1m%melt-new OBJ OBJ[m
     [1m(%melt-new f s)[m does the same, except that the unbound variables
     in [1mf[m are replaced by brand new unbound variables.

 - Procedure: [1m%copy OBJ OBJ[m
     [1m(%copy s c)[m is [1m(%freeze s f)[m followed by [1m(%melt-new f c)[m.


[4mSchelog set predicates[m

 - Syntax: [1m%bag-of OBJ GOAL OBJ[m
     [1m(%bag-of x goal bag)[m collects into bag all the values of [1mx[m for
     which goal succeeds.

 - Syntax: [1m%set-of OBJ GOAL OBJ[m
     [1m%set-of[m is similar to [1m%bag-of[m except that duplicates are weeded
     out.

 - Syntax: [1m%bag-of-1 OBJ GOAL OBJ[m
     [1m%bag-of-1[m is a variant of [1m%bag-of[m that fails if the bag  turns out
     to be empty.

 - Syntax: [1m%set-of-1 OBJ GOAL OBJ[m
     [1m%set-of-1[m is a variant of [1m%set-of[m that fails if the set turns out
     to be empty.

 - Syntax: [1m%exists LOGIC-VARIABLE GOAL[m
     [1m(%exists y goal)[m succeeds if there is an instantiation of y so
     that goal succeeds.


[4mSchelog and Scheme[m

   Since Schelog relations are just Scheme procedures, one can use
lexical scoping to define auxiliary relations, e.g., [1m%reverse[m using an
auxiliary that employs an accumulator:
[1m
     (define %reverse
       (letrec ((revaux
     	     (rel (x y z w)
     	       ((() y y))
     	       (((cons x y) z w) (revaux y (cons x z) w)))))
         (rel (x y)
           ((x y) (revaux x () y)))))
[m
   One is also not tied to the Prolog style -- regular Scheme can be
used too, treating Prolog relations as just another facility used for
local convenience along with the other facilities of Scheme.  We've
already seen that there is no difference between Schelog objects and
Scheme objects.

   To carry this one step further, Schelog predicates themselves may be
written as regular Scheme code, without much consideration for the
syntactic trappings of "rel" and "which" provided here.  To do this, one
need only exploit the facts that a Schelog goal is simply a unary
procedure that maps a failure continuation to another failure
continuation, and that unification is the key to unlocking the
information in logic variables.  Indeed, many of the predicates
provided with Schelog are coded in this fashion directly for efficiency
-- and there is no reason why your own code can't exploit this tack.
For more on this view, you may want to read the code in schelog.scm,
and read the literature on the subject, viz.,

   [1] C. Haynes, Logic continuations, J. Logic Program.  4, 1987, p.
157-176

   [2] M. Felleisen, Transliterating Prolog into Scheme, tech rept.
182, Indiana U. Comp. Sci. Dept., 1985.[m 
-----
*debug
debugging tools are still under construction.
When an error occurs during a computation, a [4mbreak loop[m is
entered where bindings in the environment of the error can be looked
at. Expression in that environment can also be evaluated. The
break loop is exited either by typing [1m#f[m -- in this case,
the computation is abandonned and a return to the top level is
performed --, or by typing [1m#t[m and the computation is continued
-- normally the error would have been corrected by interacting in the
break loop.

Example:
[1m
> (define (safe-sqrt n) 
    (and (negative? n) 
         (cerror "argument is negative !" `(sqrt ,n)))
    (sqrt n))
=> safe-sqrt
> (safe-sqrt -4)
argument is negative !(uncaught exception 'error:unknown)
in: '(sqrt -4)
break >> n
-4
break >> (set! n 4)
4
break >> #t
2
[m
These macros help debugging :
[1mshow-frame[m optionnally followed by an integer displays all
the bindings of the nth frame of the current environment.

[1m(trace! sym ['entry fun1 'env env 'exit fun2])[m
[4msym[m is a symbol defined in [4menv[m (default: the global
environment) whose value is a closure, and [4mfun1[m is a function
of one argument bound to the list of the unevaluated arguments. [4mfun1[m
is applied to the (unevaluated) called expression [1m(sym . args)[m, it defaults to
[1mwrite[m. [4mfun2[m is a function of one argument that is applied to
the result (and also defaults to [1mwrite[m).
In other words, an (already defined) function `foo'
would be traced with a call as :
[1m
> (trace! 'foo 
    'env (closure-env env-where-foo-is-defined)
    'entry (lambda (args) my-function-that-pretty-prints-args)
    'exit (lambda (result) my-function-that-pretty-prints-result))
[m
Recall that env, entry and exit arguments are optionnal.
The optionnal argument env is useful to trace a `method' of an
object (see [1mdefclass[m)

[1mtrace![m returns its argument if it has been able to set up
the tracing of the named function, and [1m#f[m otherwise.

It is not possible to trace a function that is defined (locally)
into a closure.

To cancel tracing the function [1m'foo[m, call [1m(untrace! 'foo)[m.

Example :
[1m
> (define (sum-1-to-n n) 
    (if (zero? n) 0 (+ n (sum-1-to-n (- n 1))))) => sum-1-to-n
> (trace! 'sum-1-to-n) => sum-1-to-n
> (sum-1-to-n 3)
[1] ->>  (sum-1-to-n 3)
[2] -->>  (sum-1-to-n 2)
[3] --->>  (sum-1-to-n 1)
[4] ---->>  (sum-1-to-n 0)
[4] 0 <<---- (sum-1-to-n 0)
[3] 1 <<--- (sum-1-to-n 1)
[2] 3 <<-- (sum-1-to-n 2)
[1] 6 <<- (sum-1-to-n 3)
=> 6[m 
-----
*type
The type inference system is under construction and not yet
fully documented, here are few simple examples.

Note: you must first trigger the type inference by entering [1m(set! *type* #t)[m
to get the results shown here. Don't forget to return to untype system
with [1m(set! *type* #f)[m, otherwise loading files will not function properly.

Exemples:
[1m
> (define two (lambda (x) (lambda (y) (x (x y)))))
=> two : ('a -> 'a) -> 'a -> 'a

> (two (two two)) 
=> #<closure ...> : ('a -> 'a) -> 'a -> 'a 

> (define mul4 (lambda (x) (* x 4))
=> mul4 : <exact-int> -> <exact-int>[m
[4m Yes, it assumes that [1mx[m[4m is an ``exact int'', but: [m
[1m
> (mul4 2.3) => 9.2 : <inexact-real>[m
[4m The typing is good, because the expression [m[1m(mul4 2.3)[m[4m
has been typed.[m
[1m
> (define (sum-1-to-n n) 
    (if (zero? n) 0 (+ n (sum-1-to-n (- n 1))))) 
=> sum-1-to-n : <exact-int> -> <exact-int>[m 
-----

