Back to index A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Other

Alphabetic catalog of Language elements R

random

random generates a random integer.

Category Native procedure
Format (random int)
Parameters
inta small integer
Description random generates a random number in the range [0..abs(int)-1]. int may not be 0 or an error results.
R4RS Compliance LispMe extension
Examples
(random 100) => 47
(random 100) => 11
(random -2000) => 1234
(random 0) => error

rassoc rassq rassv

rassoc, rassq, and rassv search lists containing key/value pairs.

Category Native procedures
Formats
(rassoc obj alist)
(rassq obj alist)
(rassv obj alist)
Parameters
objany object
alistan association list where each element is a pair
Description These procedures return the first element in alist, whose cdr is obj. If none is found, #f is returned. To compare obj with the values, rassoc uses equal?, rassq uses eq?, and rassv uses eqv?.
R4RS Compliance LispMe extension
Examples
(rassoc '(2) '((a 1) (b 2))) => (b 2)
(rassoc 'foo '((a 1) (b 2))) => #f
(rassq '(2) '((a 1) (b 2))) => #f
(rassq '2 '((a . 1) (b . 2))) => (b . 2)

read

read parses data read from an input port.

Category Native procedure
Format (read inport)
Parameters
inportan input port
Description read reads an object from the input port inport. It uses the standard LispMe parser to create an object from its textual representation, so all kind of syntax errors are possible. In this case, the input position of inport is not advanced. The type of the object is solely determined by the data input. If the end of file is found while reading, a unique end-of-file object (which is recognized by eof-object?) is returned.
R4RS Compliance The port parameter is not optional. Use input to let the user input an expression.
Examples
(read (open-input-file "foo")) => bar, assuming the memo "foo" starts with
bar,123...

read-char

read-char reads a single character from an input port.

Category Native procedure
Format (read-char inport)
Parameters
inportan input port
Description read-char reads a single characters from the input port inport and returns it. If the end of file is found while reading, a unique end-of-file object (which is recognized by eof-object?) is returned.
R4RS Compliance The port parameter is not optional.
Examples
(read-char (open-input-file "foo")) => #\b, assuming the memo "foo" starts with
bar,123...

read-line

read-line reads a line of text from an input port.

Category Native procedure
Format (read-line inport)
Parameters
inportan input port
Description read-line reads successive characters from the input port inport until a line feed is encountered and returns all chars read as a string. If the end of file is found while reading, a unique end-of-file object (which is recognized by eof-object?) is returned.
R4RS Compliance LispMe extension. Use input-string to let the user input a string.
Examples
(read-line (open-input-file "foo")) => "bar,123...", assuming the memo "foo" starts with
bar,123...

read-record

read-record reads a record from an arbitrary Pilot DB.

Category Deprecated use dm-read-rec instead
Format (read-record dbname recnum)
Parameters
dbnamea string naming the database
recnuman integer
Description read-record opens the Pilot database named dbname (case-sensitive!) and reads the record with index recnum from there. The record is returned as a string. If either the database or the index doesn't exist, #f is returned.
R4RS Compliance LispMe extension.
Examples
(read-record "MemoDB" 42) => "Whatever your memo contains#00"

read-resource

read-resource reads a resource from any open resource DB.

Category Deprecated use dm-read-rsrc instead
Format (read-resource restype resid)
Parameters
restypea string of 4 characters
residan integer
Description read-resource searches all open resource databases for a resource of type restype with resource id resid and returns it as a string. If the resource is not found, #f is returned.

Searched resource databases are

  1. a user interface DB opened by set-resdb
  2. LispMe itself
  3. System resources
The restype parameter determines the type of the resource to be read and is written as a string of 4 bytes, which is more readable than the Pilot API convention which builds a 32-bit integer from the 4 bytes. Please refer to the PalmOS documentation for more detailed information about Pilot resources.
R4RS Compliance LispMe extension.
Examples
(read-resource "tSTR" 9058) => "There's not enough memory to grow the memo#00", a help message from LispMe itself.

real-part

real-part computes the real part of a complex number.

Category Native procedure
Format (real-part z)
Parameters
zany number
Description real-part computes the real part of the number z.
R4RS Compliance Full
Examples
(real-part 5.1) => 5.1
(real-part 0.5+2i) => 0.5
(real-part 7.2@1.8) => -1.63585508179022

real?

real? recognizes real numbers.

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

rect

rect draws a filled rectangle.

Category Native procedure
Format (rect x y radius)
Parameters
xan integer
yan integer
radiusan integer
Description rect draws a filled rectangle from the current point stored in *gstate* to (x,y) using the colors, drawing pattern and drawing mode stored in *gstate*. radius is used for rectangles with rounded corners, it specifies the radius of a circle by which the corners are rounded. To draw a plain rectangle, use 0 for radius. After that, the current point is updated to (x,y).

See here for details on the graphic state. The return value is #n to avoid trashing the graphics.

R4RS Compliance LispMe extension
Examples
(rect 100 80 10) => #n and draws a rectangle to (100,80) with rounded (radius=10) corners as described above.

remainder

remainder divides two integers and returns the remainder.

Category Primitive procedure
Format (remainder int1 int2)
Parameters
int1an integer
int2an integer
Description remainder divides two integer numbers and returns the remainder. The sign of the result is always the sign of the dividend (or 0), in contrast to modulo. Division by zero is an error.
R4RS Compliance Full
Examples
(remainder 13 4) => 1
(remainder -13 4) => -1
(remainder 13 -4) => 1
(remainder -13 -4) => -1
(remainder 13 0) => error

reverse

reverse reverses a list.

Category Native procedure
Format (reverse list)
Parameters
lista proper list
Description reverse creates a newly allocated list consisting of the elements of list in reverse order.
R4RS Compliance Full
Examples
(reverse'(a b c d)) => (d c b a)
(reverse '((a b) (c d))) => ((c d) (a b))

rgb->index

rgb->index finds the nearest palette entry for a color.

Category Native procedure
Format (rgb->index r g b)
Parameters
ran integer in the range 0-255, red part
gan integer in the range 0-255, green part
ban integer in the range 0-255, blue part
Description rgb->index searches the system colortable (palette) for a color matching the given r g b values. The algorithm is described in the SDK docs:

Palm OS SDK Reference Palm OS 3.5 supports a maximum of 256 colors. The number of possible RGB colors greatly exceeds this amount. For this reason, an exact match may not be available. If there is no exact RGB match, then a luminance best-fit is used if the color lookup table is entirely gray scale (red, green, and blue values for each entry are identical), or a shortest-distance fit in RGB space is used if the palette contains colors. RGB shortest distance may not always produce the actual closest perceptible color, but it's relatively fast and works for the system palette.

The result is an integer denoting the best palette entry. On systems running older OS versions than 3.5, 0 is returned.

R4RS Compliance LispMe extension
Examples
(rgb->index 145 49 213) => 46 (256 colors)
(rgb->index 145 49 213) => 10 (16 grays)

rom-version

rom-version returns the version number of the PalmOS ROM.

Category Native procedure
Format (rom-version)
Parameters none
Description rom-version returns the version number of the PalmOS ROM as a hex string consisting of 8 characters. See sysFtrNumROMVersion in System/SystemMgr.h for and explanation of this number.
R4RS Compliance LispMe extension
Examples
(rom-version) => "03503001" on my Palm IIIc

round

round rounds a number to the closest integer.

Category Primitive procedure (MathLib required)
Format (round num)
Parameters
numa number
Description round converts num to a floating point number and returns the closest whole number. The result is not a LispMe integer, it's a floating point value.

See also ceiling, floor, and truncate.

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

Back to index A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Other