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 L

lambda

lambda creates a procedure.

Category Special form
Format (lambda formals expr1 expr2 ...)
Parameters
formals Either a single variable or a list of variables
  • (var1 ...) a proper list (which can be empty) of symbols. Each vari is bound to the corresponding argument when the procedure is called. The number of identifiers must be equal to the number of arguments. Procedures created by this form print as [clos n], where n is the number of identifiers.
  • var a single identifier. All arguments are gathered into a single list which is bound to var. Procedures created by this form accept any number of arguments and print as [clos -1].
  • (var1 ... . varn) an improper (dotted) list of identifiers. Each vari except varn is bound to the corresponding argument when the procedure is called. After n-1 arguments have been bound, additional arguments are gathered into a list which varn is bound to. Procedures created by this form need n-1 arguments at least and print as [clos -n].
expri the expressions which are evaluated in the extended environment when the procedure is called.
Description lambda creates a procedure (or lexical closure) defined by
  • the formal argument specifier formals
  • the sequence of expressions to be evaluated expri
  • the environment in effect when lambda is evaluated
When the procedure is called, the following steps are executed:
  1. each actual argument is evaluated
  2. the environment in effect when the procedure was created is extended by one frame consisting of formals which are bound to the arguments as described above
  3. the expressions expri are evaluated in the extended environment in the order they are written
  4. the value of the last expri evaluated is returned as the result of the application
R4RS Compliance Full
Examples
(lambda (a b) (* a (+ b 1))) => [clos 2]
((lambda x x) 1 2 3 4) => (1 2 3 4)
((lambda (x y . z) z) 1 2 3 4) => (3 4)

launch

launch starts another Palm application.

Category Primitive procedure
Format (launch [creator])
Parameters
creatora string of 4 characters, optional
Description launch searches the Palm application with creator creator and starts it. When LispMe is re-entered later, the current program is still running, so that execution continues after this procedure. When creator is omitted, the active application launcher is started and the current LispMe program is terminated, so you can use this variant to quit a LispMe app. The return value is creator. The creator 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. The ids for the builtin applications are (please note that case is significant)
dateDateBook
addrAddressBook
todoTodo List
memoMemoPad
mailMail
syncHotSync
calcCalculator
R4RS Compliance LispMe extension.
Examples
(launch "addr") => "addr" when LispMe is invoked next time, but first the AddressBook is started.

length

length returns the length of a list.

Category Native procedure
Format (length list)
Parameters
lista proper list
Description length returns the number of elements in list.
R4RS Compliance Full
Examples
(length '(a b c)) => 3
(length '((a b c))) => 1
(length '()) => 0

let

let binds local variables for expressions. It can also be used to define a recursive procedure.

Category Special form
Format (let [name] ((var form) ...) expr1 expr2 ...)
Parameters
[name] An optional name.
var ... variables. Each variable is bound to the corresponding form
form ... any LispMe expression
expri any LispMe expression. These are evaluated in sequence in the extended environment.
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.
  1. Each formi is evaluated in the current environment in an unspecified order.
  2. Each vari is bound to the value of formi.
  3. The expri are evaluated from left to right in the extended environment.
  4. The value of the last expri is the value of the let-form.
To create mutual referential bindings, use letrec.

When name is specified, a recursive function named name is created and called with the initial formi.

R4RS Compliance Full
Examples
(let ((a 2) (b 3)) (* a b)) => 6
(let ((a 2) (b 3)) (let ((a 4)) (* a b))) => 12
(let fak ((n 8)) (if (= n 0) 1 (* n (fak (- n 1))))) => 40320

let*

let* binds local variables in sequence for expressions.

Category Special form (compiler extension)
Format (let* ((var form) ...) expr1 expr2 ...)
Parameters
var ... variables. Each variable is bound to the corresponding form
form ... any LispMe expression
expri any LispMe expression. These are evaluated in sequence in the extended environment.
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.
  1. Each formi is evaluated in the current environment in sequence from left to right and may refer to earlier bound variables var<i.
  2. Each vari is bound to the value of formi.
  3. The expri are evaluated from left to right in the extended environment.
  4. The value of the last expri is the value of the let-form.
R4RS Compliance Full
Examples
(let* ((a 2) (b 3)) (* a b)) => 6
(let* ((a 2) (b 3) (a (+ a b))) (* a b)) => 15

letrec

letrec evaluates expressions in an environment with mutual referential bindings.

Category Special form
Format (letrec ((var form) ...) expr1 expr2 ...)
Parameters
var ... variables. Each variable is bound to the corresponding form
form ... any LispMe expressions
expri any LispMe expression. These are evaluated in sequence in the extended environment.
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.
  1. Extend the current lexical environment with a binding for each vari
  2. Each formi is evaluated in the extended environment in an unspecified order.
  3. Each vari is assigned to the value of formi.
  4. The expri are evaluated from left to right in the extended environment.
  5. The value of the last expri is the value of the letrec-form.
It must be possible to evaluate each formi without using the value of a vari while the extended bindings are "under construction", otherwise an error will be signalled. Normally, the formi are lambda- or delay-expressions, so this restriction is fulfilled automatically.
R4RS Compliance Full
Examples
(letrec
  ((even? (lambda n)
     (if (zero? n)
         #t
         (odd? (- n 1)))))
   (odd? (lambda (n)
     (if (zero? n)
         #f
         (even? (- n 1))))))
  (even? 42))
=> #t

list

list creates a proper list from its arguments.

Category Primitive procedure
Format (list obj1 ...)
Parameters
objiany object
Description list gathers its arguments into a proper list and returns it.
R4RS Compliance Full
Examples
(list 'a -3 "hello") => (a -3 "hello")
(list '()) => (())
(list) => ()

list*

list* creates a list from its arguments.

Category Native procedure
Format (list* obj1 obj2 ...)
Parameters
objiany object
Description list* gathers its arguments into a (possibly improper) list and returns it. The list is improper if the last argument is not a list.
R4RS Compliance LispMe extension
Examples
(list* 'a -3 "hello") => (a -3 . "hello")
(list* 'foo)) => foo
(list* 1 2 '(3 4)) => (1 2 3 4)

list->string

list->string converts a list of characters to a string.

Category Native procedure
Format (list->string charlist)
Parameters
charlista list of characters
Description list->string returns a newly allocated string consisting of the characters in charlist.
R4RS Compliance Full
Examples
(list->string '(#\F #\r #\e #\d)) => "Fred"
(list->string '(a b c)) => error
(list->string '()) => ""

list->vector

list->vector converts a list to a vector.

Category Primitive procedure
Format (list->vector list)
Parameters
lista proper list
Description list->vector returns a newly allocated vector consisting of the elements of list.
R4RS Compliance Full
Examples
(list->vector '(1 2 foo)) => #(1 2 foo)
(list->vector '()) => #()

list-ref

list-ref returns an element of a list by index.

Category Native procedure
Format (list-ref list index)
Parameters
lista proper list
indexan integer
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
(list-ref '(a b c) 1) => b
(list-ref '(a b c) 5) => error

list-tail

list-tail returns a cons cell of a list by index.

Category Native procedure
Format (list-tail list index)
Parameters
lista proper list
indexan integer
Description list-tail returns the indexth pair of list. The index of the first element is 0, and the index of the last element is the length of list minus one. The pair returned is not a copy and may be modified with set-car! etc.

For all valid indexes, the equation (list-ref lst n) = (car (list-tail lst n)) holds.

R4RS Compliance LispMe extension
Examples
(list-tail '(a b c) 1) => (b c)
(list-tail '(a b c) 3) => ()

list?

list? recognizes proper lists.

Category Primitive procedure
Format (list? obj)
Parameters
objany object
Description list? returns #t for proper list and #f for any other object. A proper list is either the empty list or a pair of any object and a (different) proper list and thus never contains a cycle.
R4RS Compliance Full
Examples
(list? '(a b c)) => #t
(list? '(a . b)) => #f
(list? 42) => #f

log

log computes the natural logarithm of a number.

Category Primitive procedure (MathLib required)
Format (log z)
Parameters
zany number
Description log returns its natural logarithm of z.
R4RS Compliance Full
Examples
(log 0) => [-inf]
(log 10) => 2.30258509299404
(log 3-4i) => 1.609437912431-0.927295218001612i

log10

log10 computes the base 10 logarithm of a number.

Category Library procedure (MathLib required)
Format (log10 z)
Parameters
zany number
Description log10 returns the logarithm to base 10 of z.
R4RS Compliance LispMe extension
Examples
(log10 2) => 0.301029995663981
(log10 1000) => 3

lookup-host

lookup-host resolves a symbolic hostname.

Category Native procedure
Format (lookup-host host)
Parameters
hosta string
Description lookup-host tries to resolve the symbolic hostname host via the DNS configured for the Palm's IP connection and returns the numeric address as a string in the standard form "n1.n2.n3.n4". If host is already a numeric IP address, it is returned unchanged. If the address cannot be resolved, #f is returned.
R4RS Compliance LispMe extension
Examples
(lookup-host "localhost") => "127.0.0.1"

lst-enter

lst-enter is posted when a list is tapped.

Category UI event
Format (lst-enter id sel)
Parameters
idthe form id of the tapped list
selthe zero-based index of the item tapped
Description lst-enter is the event posted when the user has tapped a list but not yet lifted the pen.

lst-get-sel

lst-get-sel returns the selected item in a UI list.

Category Native procedure
Format (lst-get-sel id)
Parameters
idthe form id of the list
Description lst-get-sel returns the zero-based index of the selected item in a user interface list. If no item is selected, #f is returned. The list is identified by its id.
R4RS Compliance LispMe extension
Examples
(lst-get-sel 1100) => 0 if the first item in the list with id 1100 is selected

lst-get-text

lst-get-text returns a specified item text of a UI list.

Category Native procedure
Format (lst-get-text id item)
Parameters
idthe form id of the list
selthe zero-based index of the item
Description lst-get-text returns the text of the item with zero-based index sel in the user interface list with id id as a string. If the specified item doesn't exist in the list, "" (the empty string) is returned.
R4RS Compliance LispMe extension
Examples
(lst-get-text 1100 3) => "April" assuming the list of the demo program

lst-select

lst-select is posted when a list item has been selected.

Category UI event
Format (lst-select id sel)
Parameters
idthe form id of the list
selthe zero-based index of the selected item
Description lst-select is the event posted when the user has selected an item in a list.

lst-set-list

lst-set-list fills a UI list with a list of items.

Category Native procedure
Format (lst-set-list id items)
Parameters
idthe form id of the list
itemsa proper list or a string array
Description If items is a list, lst-set-list prints each item in items using the formatting conventions of display and fills a user interface list with the strings obtained. Beginning with V3.1, any number of user-filled lists are allowed, since the items are now stored as the foreign type string array and memory management includes UI form data. A string array may also be specified for items The return value is items.
R4RS Compliance LispMe extension
Examples
(lst-set-list 1100 '(foo 3.14 "???")) => (foo 3.14 "???") and fills the list with items foo, 3.14, and ???

lst-set-sel

lst-set-sel selects an item in a UI list.

Category Native procedure
Format (lst-set-sel id sel)
Parameters
idthe form id of the list
selthe index of the item to be selected
Description lst-set-sel selects an item in a user interface list. The list is identified by its id and the item by sel, which may be either a zero-based index or the value #f meaning deselection of any item. The return value is sel.
R4RS Compliance LispMe extension
Examples
(lst-set-sel 1100 2) => 2 and selects the 3rd item in the list with id 1100

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