Back to index

Alphabetic catalog of Language elements # - C

#f

#f is the value false.

Category Constant
Format #f
Description #f is the only boolean value false. It is self-evaluating, so quoting is not necessary. Note that #f and '() are different values in LispMe, so '() means true in logical expressions.
R4RS Compliance Full
Examples
(boolean? '()) => #f
(boolean? #f) => #t
(if #f 1 0) => 0
(if '() 1 0) => 1

#n

#n is a value, which does not print.

Category Constant
Format #n
Description #n is a special object, which suppresses printing when it's the result of an evaluation. When #n is imbedded in a list, it will print as #n, but when the entire result is #n, nothing will be printed at all. This is especially useful for graphics programs, as any output caused by the REP-loop overwrites the graphics.
R4RS Compliance LispMe extension
Examples
#n => #n (but you won't see it printed)
'(#n) => (#n) (prints normally)

#t

#t is the canonical value true.

Category Constant
Format #t
Description #t is the canonical boolean value true. It is self-evaluating, so quoting is not necessary. Note that all objects other than #f mean true in logical expressions.
R4RS Compliance Full
Examples
(boolean? #t) => #t
(if #t 1 0) => 1
(if 'foo 1 0) => 1

'()

'() is the empty list.

Category Constant
Format '()
Description '() or (quote ()) is the empty list. There's no nil in LispMe (anymore), use '() instead. Though you can omit the apostrophe when writing the empty list, it's not recommended. Note that '() and #f are different values in LispMe, so '() means true in logical expressions.
R4RS Compliance Full
Examples
(null? '()) => #t
(null? #f) => #f
(pair? '()) => #f
(if '() 1 0) => 1

*

* multiplies numbers.

Category Primitive procedure
Format (* numi ...)
Parameters
numia number
Description * multiplies any number of arbitrary numbers. Type conversion (integer to real, real to complex) is handled automatically. If the product is to large to be represented as an integer, it's an error in LispMe for PalmOS1.
R4RS Compliance Full
Examples
(* 6 7) => 42
(* 1.34 2.9 0.1 93-14.7i) => 36.1398-5.71242i
(*) => 1
(* 3 'a) => error

*font*

*font* contains the font number for drawing graphic text.

Category Variable
Format *font*
Description *font* is a one-element list whose car contains the font number for drawing graphic text with text. Available fonts are
  • 0 standard font
  • 1 bold font
  • 2 large font
  • 3 symbol font
  • 4 symbol11 font
  • 5 symbol7 font
  • 6 led font
  • 7 large bold font (Palm III only)
Any other value will effect in using font 0. Note that fonts 3-6 define only a few characters in unusual positions. You should use a tool like AsciiChart to see characters and their codes on your Pilot.

You should never set! *font* to another value, because LispMe expects a fixed location for this variable, instead use set-car! to update it, or simply use the functions in the demo ; Graphic utilities.

R4RS Compliance LispMe extension

*pat*

*pat* contains the fill pattern for lines and rectangles.

Category Variable
Format *pat*
Description *pat* is a one-element list whose car contains the pattern used for graphic operations draw, rect, and text. Allowed values are
  • #f for drawing white on black
  • #t for drawing black on white
  • a string of exactly 8 bytes specifying a 8×8 fill pattern for patterned drawing
You should never set! *pat* to another value, because LispMe expects a fixed location for this variable, instead use set-car! to update it, or simply use the functions in the demo ; Graphic utilities.
R4RS Compliance LispMe extension

*point*

*point* contains the coordinates of the graphics cursor.

Category Variable
Format *point*
Description *point* is a pair whose car contains the current x coordinate and whose cdr contains the current y coordinate of the graphics cursor. These coordinates define the starting point of draw, rect, and text.

You should never set! *pat* to another value, because LispMe expects a fixed location for this variable, instead use set-car! and set-cdr! to update it, or simply use the functions in the demo ; Graphic utilities.

R4RS Compliance LispMe extension

+

+ adds numbers.

Category Primitive procedure
Format (+ numi ...)
Parameters
numia number
Description + adds any number of arbitrary numbers. Type conversion (integer to real, real to complex) is handled automatically. If the sum is to large to be represented as an integer, it's an error in LispMe for PalmOS1
R4RS Compliance Full
Examples
(+ 4 7) => 11
(+ 3.6 -2.1 8-i) => 9.5-i
(+) => 0
(+ 50 'a) => error

-

- subtracts two numbers or negates a number.

Category Primitive procedure
Format (- num1 [num2])
Parameters
num1a number
num2(optional) a number
Description When given one number, - negates it, when given two numbers, - calculates the difference of them. Type conversion (integer to real, real to complex) is handled automatically. If the difference is to large to be represented as an integer, it's an error in LispMe for PalmOS1.
R4RS Compliance Full
Examples
(- 4 7-3i) => -3+3i
(- 17.89) => -17.89
(- 'a) => error

/

/ divides two numbers or inverts a number.

Category Primitive procedure
Format (/ num1 [num2])
Parameters
num1a number
num2(optional) a number
Description When given one number, / returns its inverse, when given two numbers, / divides them. If both of them are integers and the division leaves no remainder, the result is also an integer. Type conversion (integer to real, real to complex) is handled automatically. In LispMe for PalmOS1 the result is truncated to an integer, which means that / is equivalent to quotient. Division by zero is an error.
R4RS Compliance Full
Examples
(/ 4) => 0.25
(/ 16 4) => 4
(/ 16 3) => 5.33333333333333
(/ 16 3-4i) => 1.92+2.56i
(/ 16 0) => error

< <= > >=

<, <=, >, and >= compare two objects.

Category Primitive procedures
Formats
(< comp1 comp2)
(<= comp1 comp2)
(> comp1 comp2)
(>= comp1 comp2)
Parameters
comp1a comparable object
comp2a comparable object
Description These procedures compare two objects of compatible types and return their relation, either #t or #f. Both objects must be either
  • non-complex numbers: compare arithmetically
  • chars: compare ASCII codes
  • strings: compare lexicographically
Otherwise an error is signalled.
R4RS Compliance In addition to arithmetic comparison, these procedures deal with chars and strings, too, and thus subsume the R4RS procedures char<?, char<=?, char>?, char>=?, string<?, string<=?, string>?, and string>=?.

Only two arguments are accepted in each case

Examples
(< "ab" "abc") => #t
(>= 3 3.0) => #t
(<= #\a #\A) => #f

=

= tests if a two numbers are equal.

Category Library procedure
Format (= num1 num2)
Parameters
num1a number
num2a number
Description = returns #t, if num1 is equal to num2. Otherwise it returns #f.
R4RS Compliance Full
Examples
(= 1 1.0) => #t
(= 2 3) => #f

abs

abs computes the absolute value of a number.

Category Library procedure
Format (abs num)
Parameters
numa number
Description abs computes the absolute value of num. The type of the result is the same as the argument's, with the exception of -16384, as it is not representable as an integer and therefore coerced to a float.
R4RS Compliance Full
Examples
(abs 3.4567) => 3.4567
(abs -4711) => 4711

acos

acos computes the arc cosine of a number.

Category Primitive procedure (PalmOS2 only, MathLib required)
Format (acos z)
Parameters
zany number
Description acos computes the arc cosine of z in radians.

For complex arguments z = x + yi, the formula

acos z = -i ln(z + i sqrt(1-z2))
is used.
R4RS Compliance Full
Examples
(acos 0) => 1.57079632679489
(acos -1) => 3.14159265358979
(acos 1.1) => +0.443568254385115i
(acos 0.5+2i) => 1.34977769117201-1.46571535194729i

acosh

acosh computes the hyperbolic arc cosine of a number.

Category Primitive procedure (PalmOS2 only, MathLib required)
Format (acosh z)
Parameters
zany number
Description acosh computes the hyperbolic arc cosine of z.

For complex arguments z = x + yi, the formula

acosh z = ln(z + i sqrt(1-z2))
is used.
R4RS Compliance LispMe extension
Examples
(acosh 0) => +1.57079632679489i
(acosh 1) => 0
(acosh 3) => 1.76274717403908
(acosh 0.5+2i) => 1.46571535194729+1.34977769117201i

and

and is the non-strict logical conjunction of expressions.

Category Special form
Format (and expr1 ...)
Parameters
expri any expression.
Description and evaluates the expri in left to right order. If any expression is false, the evaluation is finished. In any case, the value of the last expression evaluated is returned. Remember that '() is considered true in LispMe.
R4RS Compliance Full
Examples
(and 4 5) => 5
(and 'a "foo" #f 5) => #f
(and) => #t

angle

angle computes angle (or argument) of a complex number.

Category Primitive procedure (PalmOS2 only, MathLib required)
Format (angle z)
Parameters
zany number
Description angle computes the angle of the number z. The angle is always in the range -pi (exclusive) and pi (inclusive). See also atan.
R4RS Compliance Full
Examples
(angle 5) => 0
(angle -1) => 3.14159265358979
(angle 0.5+2i) => 1.32581766366803

append

append concatenates lists.

Category Primitive procedure
Format (append listi ...)
Parameters
listia proper list
Description append creates a list consisting of all the elements of the listi in the order of the arguments. The original lists are not modified, but the last list is not copied and shares structure with the result.
R4RS Compliance Full
Examples
(append '(a b) '(c d)) => (a b c d)
(append '(x y z) '() '(1 2 (5)) '("foo")) => (x y z 1 2 (5) "foo")
(append '(x y z) '()) => (x y z) (use this idiom to copy a list)
(append) => ()

apply

apply applies a procedure to arguments given as a list.

Category Primitive procedure
Format (apply procedure arglist)
Parameters
procedurea procedure
arglista proper list
Description apply calls procedure passing each element in arglist to procedure. The result of calling procedure is returned.

apply is especially useful when dealing with procedures with variable length argument lists, see examples.

R4RS Compliance Full
Examples
(define (sum . s)
  (if (null? s)
      0
      (+ (car s)
         (apply sum (cdr s)))))
(sum 1 2 3 4)
=> 10

asin

asin computes the arc sine of a number.

Category Primitive procedure (PalmOS2 only, MathLib required)
Format (asin z)
Parameters
zany number
Description asin computes the arc sine of z in radians.

For complex arguments z = x + yi, the formula

asin z = -i ln(iz + sqrt(1-z2))
is used.
R4RS Compliance Full
Examples
(asin 0) => 0
(asin 1) => 1.57079632679489
(asin 1.1) => 1.57079632679489-0.443568254385115i
(asin 0.5+2i) => 0.221018635622883+1.46571535194729i

asinh

asinh computes the hyperbolic arc sine of a number.

Category Primitive procedure (PalmOS2 only, MathLib required)
Format (asinh z)
Parameters
zany number
Description asinh computes the hyperbolic arc sine of z.

For complex arguments z = x + yi, the formula

asinh z = -ln(sqrt(1+z2) - z)
is used.
R4RS Compliance LispMe extension
Examples
(asinh 0) => 0
(asinh 1) => 0.881373587019543
(asinh 0.5+2i) => 1.36180090085784+1.29304207023718i

assoc assq assv

assoc, assq, and assv search lists containing key/value pairs.

Category Library procedures
Formats
(assoc obj alist)
(assq obj alist)
(assv obj alist)
Parameters
objany object
alistan association list where each element is a pair
Description These procedures return the first element in alist, whose car is obj. If none is found, #f is returned. To compare obj with the keys, assoc uses equal?, assq uses eq?, and assv uses eqv?.
R4RS Compliance Full
Examples
(assoc 'b '((a 1) (b 2))) => (b 2)
(assoc 'c '((a 1) (b 2))) => #f
(assq '(b) '(((a) 1) ((b) 2))) => #f
(assoc '(b) '(((a) 1) ((b) 2))) => ((b) 2)

atan

atan computes the arc tangent of its argument(s).

Category Primitive procedure (PalmOS2 only, MathLib required)
Format
(atan z)
(atan y x)
Parameters
zany number
xa real number
ya real number
Description atan computes the arc tangent of z in radians.

For complex arguments z = x + yi, the formula

atan z = 0.5i ln((i + z) / (i - z))
is used.

With the second form, the result is an angle whose tangent is y/x, but the signs of the arguments decide which of the two angles differing by pi is returned. It's the same value as (angle (make-rectangular x y))

R4RS Compliance Full
Examples
(atan 1) => 0.785398163397448
(atan -1 0) => -1.57079632679489
(atan 0 -1) => 3.14159265358979
(atan 0.5+2i) => 1.4215468610018+0.500370000052531i

atanh

atanh computes the hyperbolic arc tangent of a number.

Category Primitive procedure (PalmOS2 only, MathLib required)
Format (atanh z)
Parameters
zany number
Description atanh computes the hyperbolic arc tangent of z.

For complex arguments z = x + yi, the formula

atanh z = 0.5 ln((1 + z) / (1 - z))
is used.
R4RS Compliance LispMe extension
Examples
(atanh 0.5) => 0.549306144334055
(atanh -1) => [-inf]
(atanh 0.5+2i) => 0.0964156202029962+1.12655644083482i

begin

begin sequentially evaluates expressions.

Category Special form
Format (begin expr1 expr2 ...)
Parameters
expri ... expressions, which are evaluated sequentially
Description begin evaluates each expri in sequence from left to right. The value of the last expri is returned.

A second use of begin is to group mutually recursive define expressions entered into the command line.

R4RS Compliance Full
Examples
(begin 'a "foo" 42) => 42

boolean?

boolean? recognizes #t and #f.

Category Primitive procedure
Format (boolean? obj)
Parameters
objany object
Description boolean? returns #t for the boolean values #t and #f and returns #f for any other object. Remember that in LispMe () and #f are distinct objects.
R4RS Compliance Full
Examples
(boolean? '(a b c)) => #f
(boolean? '()) => #f
(boolean? #f) => #t
(boolean? #t) => #t

c...r

Any of the c...r procedures applies a sequence of car and cdr.

Category Primitive procedures
Format (c...r pair)
Parameters
paira pair
Description c...r applies a sequence of car and cdr procedures to pair and returns the result. The ... may be any combination of upto 3 a or d, where an a corresponds to car and a d corresponds to cdr. (cxyzr pair) is equivalent to (cxr (cyr (czr pair))), where each x, y and z is either a or d.
R4RS Compliance Supports upto 3 nested applications instead of 4
Examples
(caar '((a b) c)) => a
(caddr '(a b c)) => c
(cddar '((a b c) (d e f)) => (c)

call/cc

call/cc calls a procedure with the current continuation as argument.

Category Primitive procedure
Format (call/cc procedure)
Parameters
procedurea procedure of one argument
Description call/cc calls procedure with the current continuation as its argument. The current continuation is a special procedure (recognized by continuation?) of one argument and represents the remainder of the computation from the call/cc-application. The continuation may be called at any time later with any argument, which will be the result of the call/cc-application. This may happen several times, as the continuation has unlimited extent like any other LispMe object, even when call/cc has returned once.

If the continuation is not called, the value returned by procedure is the value of this call/cc-application.

R4RS Compliance The verbose name call-with-current-continuation is not supported, you probably don't want to write this with Graffiti!
Examples
(call/cc (lambda (k) (* 3 (k 5)))) => 5
(((call/cc (lambda (x) x))
           (lambda (y) y)) 'foo)
=> foo (how does this work ? :-))

car

car returns the car component of a pair.

Category Primitive procedure
Format (car pair)
Parameters
paira pair
Description car returns the car component of pair. The car component is the first argument given in the cons procedure.

For related information, see cdr and cons.

R4RS Compliance Full
Examples
(car '(a b c)) => a
(car '((a b c))) => (a b c)
(car '(a . b)) => a
(car '()) => error

case

case tests a value against some constant lists and evaluates expressions associated with the first match.

Category Special form
Format (case expr (guard expr1 expr2 ...) ...)
Parameters
expr the expression to be tested.
guard ... may be either a list of values, or the keyword else.
expri ... expressions, which are evaluated sequentially, if the corresponding guard matches.
Description case first evaluates expr and tests sequentially, if its value is (using eqv?) in one of the constant lists guard. When the first match is encountered, its corresponding expri are evaluated from left to right and the value of the last expri is returned.

Note that the constant lists must not be quoted! The special keyword else can be used for an "otherwise" clause. It's an error, if no guard matches.

R4RS Compliance Full
Examples
(case 5 ((1 3 4 8) 'foo)
        ((2 5 6)   'bar)
        (else      'baz))
=> bar
(case 9 ((1 3 4 8) 'foo)
        ((2 5 6)   'bar))
=> error

cdr

cdr returns the cdr component of a pair.

Category Primitive procedure
Format (cdr pair)
Parameters
paira pair
Description cdr returns the cdr component of pair. The cdr component is the second argument given in the cons procedure.

For related information, see car and cons.

R4RS Compliance Full
Examples
(cdr '(a b c)) => (b c)
(cdr '((a b c))) => ()
(cdr '(a . b)) => b
(cdr '()) => error

ceiling

ceiling computes the smallest whole number greater than or equal to a number.

Category Primitive procedure (PalmOS2 only, MathLib required)
Format (ceiling num)
Parameters
numa number
Description ceiling converts num to a floating point number and returns the smallest whole number greater than or equal to num. The result is not a LispMe integer, it's a floating point value

See also floor, round, and truncate.

R4RS Compliance Full
Examples
(ceiling -4.3) => -4
(ceiling 3.5) => 4

char->integer

char->integer converts a character to its ASCII code.

Category Primitive procedure
Format (char->integer char)
Parameters
chara character
Description char->integer returns the ASCII code of char. You should use a tool like AsciiChart to see characters and their codes on your Pilot.
R4RS Compliance Full
Examples
(char->integer #\F) => 70
(char->integer #\ü) => 252

char?

char? recognizes characters.

Category Primitive procedure
Format (char? obj)
Parameters
objany object
Description char? returns #t for a character and #f for any other object.
R4RS Compliance Full
Examples
(char? #\x) => #t
(char? "x") => #f
(char? 'x) => #f

complex?

complex? recognizes complex numbers.

Category Primitive procedure
Format (complex? obj)
Parameters
objany object
Description complex? returns #t for integer, real and complex numbers and #f for any other object. In fact, it's the same procedure as number?
R4RS Compliance Full
Examples
(complex? 42) => #t
(complex? -1.234e-55) => #t
(complex? 3.5-17i) => #t
(complex? 'foo) => #f

cond

cond sequentially tests conditions and evaluates expressions associated with the first true one.

Category Special form
Format (cond (guard expr1 expr2 ...) ...)
Parameters
guard ... any expression including the keyword else.
expri ... expressions, which are evaluated sequentially, if the corresponding guard is true.
Description cond evaluates each guard in sequence. When the first true guard is encountered, its corresponding expri are evaluated from left to right and the value of the last expri is returned.

The special keyword else, which is always true, can be used for an "otherwise" clause. It's an error, if no guard is true.

R4RS Compliance Expression sequence in each clause must not be empty
Examples
(cond ((< 6 1) 'a)
      ((> 6 1) 'b))
=> b
(cond ((< 6 6) 'a)
      ((> 6 6) 'b)
      (else    'c))
=> c
(cond (#f 0)) => error

cons

cons creates a freshly allocated pair.

Category Primitive procedure
Format (cons obj1 obj2)
Parameters
obj1any object
obj2any object
Description cons returns a freshly allocated pair whose car component is obj1 and whose cdr component is obj2. The new pair is always unique, i.e. it is not eq? to any other object. The procedures car and cdr are used to access the components of the pair.
R4RS Compliance Full
Examples
(cons 'a 'b) => (a . b)
(cons 1 '()) => (1)
(cons '(a) '(b)) => ((a) b)

continuation?

continuation? recognizes continuations.

Category Primitive procedure
Format (continuation? obj)
Parameters
objany object
Description continuation? returns #t for a continuation created with call/cc and #f for any other object.
R4RS Compliance Full
Examples
(continuation? (lambda (x) x)) => #f
(call/cc continuation?) => #t
(continuation? 'foo) => #f

cos

cos computes the cosine of a number.

Category Primitive procedure (PalmOS2 only, MathLib required)
Format (cos z)
Parameters
zany number
Description cos computes the cosine of the number z. z is an angle measured in radians.

For complex arguments z = x + yi, the formula

cos z = cosx coshy - i sinx sinhy
is used.
R4RS Compliance Full
Examples
(cos 0) => 1
(cos 1) => 0.54030230586814
(cos 0.5+2i) => 3.30163733291409-1.73880950447431i

cosh

cosh computes the hyperbolic cosine of a number.

Category Primitive procedure (PalmOS2 only, MathLib required)
Format (cosh z)
Parameters
zany number
Description cosh computes the hyperbolic cosine of the number z.

For complex arguments z = x + yi, the formula

cosh z = coshx cosy + i sinhx siny
is used.
R4RS Compliance LispMe extension
Examples
(cosh 0) => 1
(cosh 1) => 1.54308063481524
(cosh 0.5+2i) => -0.469257978229053+0.473830620416407i

Catalog of Language Elements D - L

Catalog of Language Elements M - R

Catalog of Language Elements S - Z