Catalog of Language Elements # - C
Category | Special form | ||||||||
Format |
|
||||||||
Parameters |
|
||||||||
Description | define associates a name with a value. The first form
simply evaluates an expression and binds a name to it. The second
form creates a procedure with the parameters formals
as described at lambda
and binds var to it. In LispMe, every name used must have been defined before, so every variable used in expri must have been defined in the same binding group (see loading), in a previously loaded memo or manual definition before, or in the case of a local definition, in the enclosing construct. In fact, a group of definitions (like a memo to be loaded, or a list of definitions enclosed in a begin expression entered into the command line) or a group of local definitions is treated like a letrec binding group; this means that every name used in this group must have been defined before or must be defined in this binding group (for mutual recursive definitions). This assures that every name can be statically resolved at compile time and there's no symbol table left to be checked at runtime. Each source memo must consist of a sequence of define-expressions. You can enter definitions in the REP-loop, and each definition will create a frame with a single variable binding. Local definitions are allowed whereever an expression sequence is. (The body of a begin-, case-, cond-, lambda-, let-, or letrec-expression) In this case, all definitions must occur before any other expression in the body or you'll see this error. The return value of a definition is #n in this implementation. | ||||||||
R4RS Compliance | See here | ||||||||
Examples |
|
Category | Special form | ||||||
Format | (delay expr) | ||||||
Parameters |
|
||||||
Description | delay packages expr together with the current lexical environment into a promise, which may be evaluated (using force) later. The first time the promise is forced, the delayed expression will be evaluated in the captured environment, and the result will be memoized. Subsequent forcing of this promise always returns the memoized value. | ||||||
R4RS Compliance | Full | ||||||
Examples |
|
Category | Primitive procedure | |||
Format | (delete-file string) | |||
Parameters |
|
|||
Description | delete-file deletes the memo with name
string from the MemoPad database. Deleting is
done with the DmRemoveRecord function, so the memo
is actually deleted (not just its delete-flag set), so if you
hotsynced the memo to your desktop, the next HotSync will
restore it onto your Pilot, as HotSync has no indication that
the memo has been deleted on the Pilot and it assumes that the
memo was freshly created on the desktop. So there's no danger
loosing valuable memos when they have been hotsynced. The return value is #n. |
|||
R4RS Compliance | LispMe extension | |||
Examples |
|
Category | Primitive procedure | |||
Format | (dir) | |||
Parameters | none | |||
Description | dir creates a list of the names of all memos in the MemoPad database. A memo name is its first line, truncated to 16 characters like all file names are handled in LispMe. | |||
R4RS Compliance | LispMe extension | |||
Examples |
|
Category | Primitive procedure | |||
Format | (disasm closure) | |||
Parameters |
|
|||
Description | disasm returns the SECD code of a closure
(see lambda) as a list.
You should never modify this list with
set-car! or the like, as you'll probably get
this error or even
a Fatal exception! This procedure is intended for debugging purposes and the curious LispMe user. You can obtain an opcode list by me, if you're interested. | |||
R4RS Compliance | LispMe extension | |||
Examples |
|
Category | Primitive procedure | ||||||
Format | (display obj [outport]) | ||||||
Parameters |
|
||||||
Description | display prints an object to the output field or to the output port outport in human-readable format, i.e. strings and chars are not escaped. No space is appended after output. display returns obj. Printing objects is described here. For related information, see newline and write. | ||||||
R4RS Compliance | Full | ||||||
Examples |
|
Category | Special form (library) | ||||||||||||
Format | (do ((var init step) ...) (test expr ...) (stmt ...)) | ||||||||||||
Parameters |
|
||||||||||||
Description | do is a general looping mechanism. First, each
initi is evaluated in an unspecified
order and each vari is bound to the
corresponding value. On each iteration, test is evaluated first. When it is true, the exprj are evaluated in left to right order and the value of the last one is returned as the value of the whole do expression. If it is false, the stmtk are evaluated in left to right order. Next, all vari are updated by evaluating the corresponding stepi and the next iteration begins. | ||||||||||||
R4RS Compliance | Full | ||||||||||||
Examples |
|
Category | Primitive procedure | ||||
Format | (draw x y) | ||||
Parameters |
|
||||
Description | draw draws a line from the current point
*point* to (x,y)
using the drawing pattern
*pat*.
After that, *point* is updated
to (x,y).
Allowed patterns are
|
||||
R4RS Compliance | LispMe extension | ||||
Examples |
|
Category | Primitive procedure | ||||||
Format | (eof-object? obj) | ||||||
Parameters |
|
||||||
Description | eof-object? returns #t for the end-of-file object, which is returned by procedures read, read-char, peek-char, and read-line when they encounter the end of a memo; and #f for any other object. | ||||||
R4RS Compliance | Full | ||||||
Examples |
|
Category | Primitive procedure | |||||||||||||||||||||
Format | (eq? obj1 obj2) | |||||||||||||||||||||
Parameters |
|
|||||||||||||||||||||
Description | eq? returns #t if obj1 and obj2 are identical and #f otherwise. eq? identifies equal symbols, integers and chars, but not reals or strings. To compare reals, use eqv? and to compare strings use string=? or equal?. Empty lists, vectors and strings are always eq?. | |||||||||||||||||||||
R4RS Compliance | Full | |||||||||||||||||||||
Examples |
|
Category | Library procedure | ||||||||||||||||||
Format | (equal? obj1 obj2) | ||||||||||||||||||
Parameters |
|
||||||||||||||||||
Description | equal? returns #t if obj1 and obj2 have the same value and #f otherwise. equal? returns #t, if eqv? does, but also if both objects are lists, vectors or strings and contain the same components. In general, two objects are equal? if they print the same way. equal? may not terminate on circular lists. | ||||||||||||||||||
R4RS Compliance | Full | ||||||||||||||||||
Examples |
|
Category | Primitive procedure | |||||||||||||||||||||
Format | (eqv? obj1 obj2) | |||||||||||||||||||||
Parameters |
|
|||||||||||||||||||||
Description | eq? returns #t if obj1 and obj2 are equivalent and #f otherwise. eqv? returns #t, if eq? does, but also if both objects are numbers and numerically the same. Different non-empty strings are never considered eqv?, as modifying one string does not alter the other and so they're not equivalent. (Remember that strings are not shared in LispMe.) | |||||||||||||||||||||
R4RS Compliance | Full | |||||||||||||||||||||
Examples |
|
Category | Primitive procedure | ||||||
Format | (error obj) | ||||||
Parameters |
|
||||||
Description | error aborts the current evaluation and prints obj using display to a message box as a user error. There's no return value. | ||||||
R4RS Compliance | LispMe extension | ||||||
Examples |
|
Category | Primitive procedure | ||||||
Format | (eval expression) | ||||||
Parameters |
|
||||||
Description | eval evaluates expression in the current environment and returns its value. | ||||||
R4RS Compliance | LispMe extension. The environment parameter described in R5RS is not supported. | ||||||
Examples |
|
Category | Library procedure | ||||||
Format | (even? int) | ||||||
Parameters |
|
||||||
Description | even? returns #t, if int is even. Otherwise it returns #f. See also odd?. | ||||||
R4RS Compliance | Full | ||||||
Examples |
|
Category | Library procedure | |||
Format | (exact? num) | |||
Parameters |
|
|||
Description | exact? always returns #f, as LispMe doesn't support the exactness property of numbers. See also inexact?. | |||
R4RS Compliance | Exactness property not supported | |||
Examples |
|
Category | Primitive procedure (PalmOS2 only, MathLib required) | |||||||||
Format | (exp z) | |||||||||
Parameters |
|
|||||||||
Description | exp returns the natural antilogarithm ex of z. | |||||||||
R4RS Compliance | Full | |||||||||
Examples |
|
Category | Library procedure (PalmOS2 only, MathLib required) | ||||||||||||
Format | (expt z1 z2) | ||||||||||||
Parameters |
|
||||||||||||
Description | expt returns the power z1z2. | ||||||||||||
R4RS Compliance | Full | ||||||||||||
Examples |
|
Category | Primitive procedure (PalmOS2 only, MathLib required) | ||||||
Format | (floor num) | ||||||
Parameters |
|
||||||
Description | floor converts num to a floating point number and returns the largest whole number less than or equal to num. The result is not a LispMe integer, it's a floating point value. | ||||||
R4RS Compliance | Full | ||||||
Examples |
|
Category | Library procedure | ||||
Format | (for-each proc list) | ||||
Parameters |
|
||||
Description | for-each applies proc to each element in list strictly from left to right, ignoring the values returned. | ||||
R4RS Compliance | Supports only one list | ||||
Examples |
|
Category | Primitive procedure | ||||||
Format | (force prom) | ||||||
Parameters |
|
||||||
Description | force evaluates a promise created by delay. If the promise hasn't already been evaluated, it's evaluated now and the result is memoized. Subsequent forcing of this promise will always return the memoized value. | ||||||
R4RS Compliance | Full | ||||||
Examples |
|
Category | Primitive procedure | ||||||
Format | (gensym) | ||||||
Parameters | none | ||||||
Description | gensym creates a new symbol, which is not eq? to any other symbol, no matter if input or created by a different call to gensym. This is guaranteed by using an uppercase G, which cannot be input, as all symbols entered are generally converted to lower case. | ||||||
R4RS Compliance | LispMe extension | ||||||
Examples |
|
Category | Special form | |||||||||
Format | (if test consequent alternative) | |||||||||
Parameters |
|
|||||||||
Description | if evaluates test first. If this evaluates to true, consequent is evaluated and its value returned. Otherwise, alternative is evaluated and its value returned. Remember that '() is considered true in LispMe. | |||||||||
R4RS Compliance | alternative is not optional | |||||||||
Examples |
|
Category | Primitive procedure (PalmOS2 only) | |||||||||
Format | (imag-part z) | |||||||||
Parameters |
|
|||||||||
Description | imag-part computes the imaginary part of the number z. | |||||||||
R4RS Compliance | Full | |||||||||
Examples |
|
Category | Library procedure | |||
Format | (inexact? num) | |||
Parameters |
|
|||
Description | inexact? always returns #t, as LispMe doesn't support the exactness property of numbers. See also exact?. | |||
R4RS Compliance | Exactness property not supported | |||
Examples |
|
Category | Primitive procedure | |||
Format | (input prompt) | |||
Parameters |
|
|||
Description | input displays a dialog where the user can input a LispMe object which will be returned. prompt is displayed as a prompt text in the input dialog. input uses the standard LispMe parser to create an object from its textual representation, so all kind of syntax errors are possible. The type of the object is solely determined by the data input. | |||
R4RS Compliance | LispMe extension. Note that this procedure was called read in earlier versions. This has been changed to avoid confusion with the R4RS read. | |||
Examples |
|
Category | Primitive procedure | |||||||||
Format | (input-port? obj) | |||||||||
Parameters |
|
|||||||||
Description | input-port? returns #t for a port opened for input by open-input-file and #f for any other object. | |||||||||
R4RS Compliance | Full | |||||||||
Examples |
|
Category | Primitive procedure | |||
Format | (input-string prompt) | |||
Parameters |
|
|||
Description | input-string displays a dialog where the user can input any text which will be returned as a string. prompt is displayed as a prompt text in the input dialog. input-string accepts any text entered. | |||
R4RS Compliance | LispMe extension. Note that this procedure was called read-string in earlier versions. This has been changed to be consistent with input. | |||
Examples |
|
Category | Primitive procedure (PalmOS2 only) | ||||||
Format | (integer num) | ||||||
Parameters |
|
||||||
Description | integer converts the floating point number num to an integer by truncating. If num is already an integer, integer just returns it. It's an error, if num is not in the range [-16384...16383]. See also truncate. | ||||||
R4RS Compliance | LispMe extension | ||||||
Examples |
|
Category | Primitive procedure | ||||||
Format | (integer->char int) | ||||||
Parameters |
|
||||||
Description | integer->char returns the char with the ASCII code int. Only the lower 8 bit of int are used (int mod 256). You should use a tool like AsciiChart to see characters and their codes on your Pilot. | ||||||
R4RS Compliance | Full | ||||||
Examples |
|
Category | Primitive procedure | ||||||||||||
Format | (integer? obj) | ||||||||||||
Parameters |
|
||||||||||||
Description | integer? returns #t for integer numbers and #f for any other object. In LispMe for PalmOS1 integer? is the same procedure as number?, as real and complex numbers are not available. | ||||||||||||
R4RS Compliance | Full | ||||||||||||
Examples |
|
Category | Variable |
Format | it |
Description | it is a variable which it automatically updated to the result of the last evaluation, so you can use it in subsequent evaluations. |
R4RS Compliance | LispMe extension |
Category | Special form | |||||||||
Format | (lambda formals expr1 expr2 ...) | |||||||||
Parameters |
|
|||||||||
Description | lambda creates a procedure (or lexical closure)
defined by
| |||||||||
R4RS Compliance | Full | |||||||||
Examples |
|
Category | Library procedure | |||||||||
Format | (length list) | |||||||||
Parameters |
|
|||||||||
Description | length returns the number of elements in list. | |||||||||
R4RS Compliance | Full | |||||||||
Examples |
|
Category | Special form | ||||||
Format | (let ((var form) ...) expr1 expr2 ...) | ||||||
Parameters |
|
||||||
Description | let is a binding form, which extends the lexical
environment by the bindings in its head and evaluates its body
forms in the extended environment.
| ||||||
R4RS Compliance | Full | ||||||
Examples |
|
Category | Special form (library) | ||||||
Format | (let* ((var form) ...) expr1 expr2 ...) | ||||||
Parameters |
|
||||||
Description | let* is a binding form, which extends the lexical
environment by the bindings in its head and evaluates its body
forms in the extended environment.
| ||||||
R4RS Compliance | Full | ||||||
Examples |
|
Category | Special form | ||||||
Format | (letrec ((var form) ...) expr1 expr2 ...) | ||||||
Parameters |
|
||||||
Description | letrec is a binding form, which extends the lexical
environment by the bindings in its head and evaluates its body
forms in the extended environment. In contrast to
let, each
vari is in scope while
formj is evaluated, so mutual recursive
definitions are possible.
| ||||||
R4RS Compliance | Full | ||||||
Examples |
|
Category | Primitive procedure | |||||||||
Format | (list obj1 ...) | |||||||||
Parameters |
|
|||||||||
Description | list gathers its arguments into a list and returns it. | |||||||||
R4RS Compliance | Full | |||||||||
Examples |
|
Category | Primitive procedure | |||||||||
Format | (list->string charlist) | |||||||||
Parameters |
|
|||||||||
Description | list->string returns a newly allocated string consisting of the characters in charlist. | |||||||||
R4RS Compliance | Full | |||||||||
Examples |
|
Category | Primitive procedure | ||||||
Format | (list->vector list) | ||||||
Parameters |
|
||||||
Description | list->vector returns a newly allocated vector consisting of the elements of list. | ||||||
R4RS Compliance | Full | ||||||
Examples |
|
Category | Library procedure | ||||||
Format | (list-ref list index) | ||||||
Parameters |
|
||||||
Description | list-ref returns the indexth element of list. The index of the first element is 0, and the index of the last element is the length of list minus one. | ||||||
R4RS Compliance | Full | ||||||
Examples |
|
Category | Primitive procedure (PalmOS2 only, MathLib required) | |||||||||
Format | (log z) | |||||||||
Parameters |
|
|||||||||
Description | log returns its natural logarithm of z. | |||||||||
R4RS Compliance | Full | |||||||||
Examples |
|
Category | Library procedure (PalmOS2 only, MathLib required) | ||||||
Format | (log10 z) | ||||||
Parameters |
|
||||||
Description | log10 returns the logarithm to base 10 of z. | ||||||
R4RS Compliance | LispMe extension | ||||||
Examples |
|