Star Sapphire Common LISP Home

Download Star Saphire
Index

LISP: LAMBDA-LIST-KEYWORD

see LAMBDA

LISP: LAMBDA LIST

see LAMBDA

LISP: LAMBDA

C: E_Lambda

min args: 0

max args: -1

[Lambda][CLTL 5]

SYNOPSIS:

(lambda ({var}*

[&optional {var | (var initform [svar]])}*]

[&rest var]

[&key {var | (keyword var)} [initform [svar]])}*

[&allow-other-keys]]

[&aux {var | (var [initform])}*])

{declaration | documentation-string}*

{form}*)

DESCRIPTION:

For detailed descriptions of each lambda list keyword, to the following related articles:

Required Parameters

&optional parameters

&rest parameter

&key parameters

&allow-other-keys

&aux parameters

Lambda List Examples

overview

A lambda expression defines a functional object.

A lambda list is used to define how the external world is to communicate with that object, in particular how parameters get bound to arguments when the function is invoked.

A list form with functional meaning can either have a symbol or a list at its head. If it has a symbol, then that symbols' functional object is obtained and applied to the arguments which follow it in the list, e.g.:

(+ 3 4 5)

=>

12

Some symbols (such as +) have predefined functional meaning, in this case addition. The user can also define functional meaning for symbols using defun:

(defun add-3-numbers(x y z)

(+ x y z))

(add-3-numbers 3 4 5)

=>

12

If the object at the head of a list to be evaluated is a list itself, it must be in the format given in the synopsis. Such a list must have the symbol lambda at its head. Conversely, it is an error if the interpreter is given a form consisting of a list with a list at its head not beginning with the symbol lambda; such errors usually result from not quoting a piece of complicated list structure at the proper level.

EXAMPLES:

((lambda (x y z) (+ x y z)) ; define a function on the fly

3 4 5) ; arguments for the function

=>

12

A lambda can be thought of as an anonymous function. Lambda is most useful when combined with the function special form to produce a closure.

Normally learning about lambda per se is not vital; programmers can go quite far into LISP and never have to use lambda.

The reason that this entry is of key importance (and should be studied closely, even by beginners) is that the lambda list syntax which defines lambda parameter lists is shared by the much more commonly used defun and defmacro.

It may help to review the difference between a parameter and an argument.

Each element of a lambda-list is either a parameter specifier or a lambda-list keyword; lambda-list keywords are written and printed like symbols whose name begins with an ampersand (&). See the notes for this entry for implementation details.

Lambda list breakdown

A lambda-list has five parts, all of which are optional.

The body of a lambda expression consists of any number of forms (possibly zero). The arguments can be referred to in the scope of the body using the parameter names. The forms which make up the body are evaluated as an implicit progn. That is, the forms are evaluated in sequence, and the results of the last form are returned as the result of the lambda expression. As a base case, the value nil is returned if there are no forms in the body.

The forms in the body of the lambda-expression are executed after the lambda-list has been processed. Forms in the body may refer to the arguments to the function by using the names of the parameters. On exit from the function the parameter bindings whether lexical or special, will no longer be in effect. The function can be exited when the last form in the implicit progn is evaluated or through the execution of a return or return-from form.

NOTES:

It is permitted to specify both &rest and &key. In this case any remaining arguments are used for both purposes. All remaining arguments are made into a list for the &rest parameter. Furthermore, they are also processed for the &key parameters. This is the only situation in which an argument is used in the processing of more than one parameter specifier.

Matching keyword parameters with arguments is quite time consuming. More formally, the time cost to match these items up can be order n times m (where n is the number of parameters and m is the number of arguments). This should be kept in mind when using the keyword feature of lambda lists.

Whenever an initform is evaluated for any parameter specifier, that form may refer to any parameter variable to the left of the specifier in which the initform appears. This includes any supplied-p variables. No other parameter variable will have yet been bound when an initform is evaluated, including its own parameter variable.

Lambda-list keywords are not keywords in the usual sense; they do not belong to the keyword package. This terminology is confusing but is retained for historical reasons. In Star Sapphire LISP lambda-list keywords, for speed of processing, are implemented as immediate objects whose type will be reported as lambda-list-keyword; they are not even symbols but virtual addresses with distinct type bits, one per keyword. In other Common LISP implementations, these objects might be implemented as normal symbols.

All symbols whose names begin with & are conventionally reserved for use as lambda-list keywords and should not be used as variable names. Implementations of Common LISP are free to provide additional lambda-list keywords (Star Sapphire does not).

 

REQUIRED PARAMETERS

When the function represented by the lambda-expression is applied to arguments, the arguments and parameters are processed in order from left to right.

In the simplest case, only required parameters are present in the lambda-list; each is specified simply by a name var for the parameter variable. When the function is applied, there must be exactly as many arguments as there are parameters, and each parameter is bound to one argument. Here, and in general, the parameter is bound as a lexical variable unless a declaration has been made that it should be a special binding.

In the more general case, if there are zero or more required parameters there must be at least the same number of arguments, and the required parameters are bound in sequence to the matching arguments.

Any non-required parameters are then processed using remaining arguments.

Back to lambda

 

&OPTIONAL PARAMETERS

If optional parameters are specified, then each one is processed as follows. If any unprocessed arguments remain, then each parameter is bound to the next remaining argument in sequence, just as for a required parameter.

If no arguments remain, however, then the initform part of the parameter specifier, if any, is used. The parameter variable is bound to be the value specified by the evaluating the initform. Note that the initform is not evaluated until the parameter list is actually used.

If no initform appears in the parameter specifier, then the argument will be bound to nil.

The svar argument is used to tell whether the supplied initform was used or not. If it is present, it is bound to t if the initform was evaluated and bound to the given parameter, and nil otherwise.

In all cases where var or svar appears in lambdas' synopsis it must be a symbol which is to serve as the name of a variable. An initform may be any LISP form whatsoever.

Back to lambda

 

&REST PARAMETER

After all optional parameter specifiers have been processed, then there may or may not be a rest parameter, preceeded by a &rest lambda list keyword. If there is a rest parameter, it is bound to a list of all as-yet-unprocessed arguments. If no unprocessed arguments remain, the rest parameter is bound to the empty list. If there is no rest parameter and there are no keyword parameters, then it is an error if there are unprocessed arguments at this point.

Back to lambda

 

&KEY PARAMETERS

Next, any keyword parameters are processed. For this purpose the same residual arguments are processed that would be made into a list for a rest parameter (see NOTES).

If &key is specified, there must remain an even number of arguments following the &key lambda list keyword up to the end of the list or the next lambda list keyword. These are considered as pairs. The first argument in each pair is interpreted as a keyword name. The second is used as the corresponding value.

It is an error for the first object of each pair to be anything but a keyword. That is, each keyword must be a keyword symbol, such as :start.

In each keyword parameter specifier must be a symbol to be used for the variable name. If an explicit keyword is specified, then that is the keyword name for the parameter. Otherwise the var serves to indicate the keyword name, in that a symbol with the same name in the keyword package is used as the keyword. For example:

(lambda (&key x (y 3)) ...)

means the same thing as

(lambda (&key ((:x x)) ((:y y) 3)) ...)

The keyword parameter specifiers are processed from left to right. In each case, a search for a matching argument keyword is attempted, also from left to right.

For each keyword parameter specifier, if there is an argument pair whose keyword name matches (is eq to) that specifier's keyword name, then the parameter variable for that specifier is bound to the second item (the value) of that argument pair.

It is NOT an error if more than one such argument pair matches. If there is more than one then the leftmost argument pair is used, that is, the search drops out at the first match.

If no argument pair exists for a parameter, then the initform for that specifier is evaluated and the parameter variable is bound to that value. The variable will be bound to nil if no initform is specified. The variable svar is treated as for optional parameters: It is bound to t if there is a matching argument pair, and to nil otherwise.

Back to lambda

 

&ALLOW-OTHER-KEYS

It is an error if an argument pair has a keyword name not matched by any parameter specifier, unless at least one of the following two conditions is met:

&allow-other-keys is specified in the lambda-list following the keywords.

Among the keyword argument pairs is a pair whose keyword is :allow-other-keys and whose value is not nil.

If one of these conditions is met, then it is not an error for an argument pair to match no parameter specified, and any such argument pair is simply ignored. These an argument pairs can be accessed through the &rest parameter if present.

Back to lambda

 

 

&AUX PARAMETERS

After all parameter specifiers have been processed, the auxiliary variable specifiers (those following the lambda-list keyword &aux) are processed from left to right.

For each one, the initform is evaluated and the variable var bound to that value (or to nil if no initform was specified). The &aux parameters are processed as if a let* was wrapped around the body of the function:

(lambda (x y &aux (a (* x x)) (b a) c) ...)

(lambda (x y) (let* ((a (* x x)) (b a) c) ...))

It is fairly common to have some local variables in a function and define them using a let or let* form. The &aux syntax can be used as a shorthand for this. Whether or not to use this feature is completely up to the programmer.

Back to lambda

 

 

LAMBDA LIST EXAMPLES

Examples of &optional and &rest parameters:

((lambda (a b) (+ a (* b 3)))

4 5)

=>

19

((lambda (a &optional (b 2)) (+ a (* b 3)))

4 5)

=>

19

((lambda (a &optional (b 2)) (+ a (* b 3)))

4)

=>

10

((lambda (&optional (a 2 b) (c 3 d) &rest x) (list a b c d x))

) ; no arguments

=> (2 nil 3 nil nil)

((lambda (&optional (a 2 b) (c 3 d) &rest x) (list a b c d x))

6)

=> (6 t 3 nil nil)

((lambda (&optional (a 2 b) (c 3 d) &rest x) (list a b c d x))

6 3)

=> (6 t 3 t nil)

((lambda (&optional (a 2 b) (c 3 d) &rest x) (list a b c d x))

6 3 8)

=> (6 t 3 t (8))

((lambda (&optional (a 2 b) (c 3 d) &rest x) (list a b c d x))

6 3 8 9 10 11)

=> (6 t 3 t (8 9 10 11))

 

Examples of &key parameters:

((lambda (a b &key c d) (list a b c d))

1 2)

=> (1 2 nil nil)

((lambda (a b &key c d) list a b c d))

1 2 :c 6)

=> (1 2 6 nil)

((lambda (a b &key c d) (list a b c d))

1 2 :d 8)

=> (1 2 nil 8)

((lambda (a b &key c d) (list a b c d))

1 2 :c 6 :d 8)

=> (1 2 6 8)

((lambda (a b &key c d) (list a b c d))

1 2 :d 8 :c 6)

=> (1 2 6 8)

((lambda (a b &key c d) (list a b c d))

:a 1 :d 8 :c 6)

=> (:a 1 6 8)

((lambda (a b &key c d) (list a b c d))

:a :b :c :d)

=> (:a :b :d nil)

 

Examples of mixtures:

((lambda (a &optional (b 3) &rest x &key c (d a)) (list a b c d x))

1)

=> (1 3 nil 1 ())

((lambda (a &optional (b 3) &rest x &key c (d a)) (list a b c d x))

1 2)

=> (1 2 nil 1 ())

((lambda (a &optional (b 3) &rest x &key c (d a)) (list a b c d x))

:c 7)

=> (:c 7 nil :c ())

((lambda (a &optional (b 3) &rest x &key c (d a)) (list a b c d x))

1 6 :c 7)

=> (1 6 7 1 (:c 7))

((lambda (a &optional (b 3) &rest x &key c (d a)) (list a b c d x))

1 6 :d 8)

=> (1 6 nil 8 (:d 8))

((lambda (a &optional (b 3) &rest x &key c (d a)) (list a b c d x))

1 6 :d 8 :c 9 :d 10)

=> (1 6 9 8 (:d 8 :c 9 :d 10))

 

LISP: LAMBDA-LIST-KEYWORDS

[Constant][CLTL 5]

SYNOPSIS:

lambda-list-keywords

DESCRIPTION:

The value of lambda-list-keywords is a list of all the lambda-list keywords used in the implementation, including the additional ones used only by defmacro . This list contains the symbols &optional, &rest, &key, &allow-other-keys, &aux, &body, &whole, and &environment.

See Also:

lambda, &optional, &rest, &key, &allow-other-keys, &aux, &body, &whole, and &environment

NOTES:

This constant is defined in init0.lsp. By default, it is not loaded at startup to reduce the time needed to initialize LISP. If needed, its definition can be added to init.lsp so that it will be initialized at startup; it can also be added to any file of LISP code.

LISP: LAMBDA-PARAMETERS-LIMIT

[Constant][CLTL 5]

SYNOPSIS:

lambda-parameters-limit

DESCRIPTION:

The value of lambda-parameters-limit is a positive integer that is the upper exclusive bound on the number of distinct parameter names that may appear in a single lambda-list. This number in Star Sapphire Common LISP is equal to one less than the largest positive fixnum available on the system. See call-arguments-limit.

NOTES:

This constant is defined in init0.lsp. By default, it is not loaded at startup to reduce the time needed to initialize LISP. If needed, its definition can be added to init.lsp so that it will be initialized at startup; it can also be added to any file of LISP code.

LISP: LAST

C: Llast

min args: 1

max args: 1

[F][CLTL 15]

SYNOPSIS:

last list

DESCRIPTION:

last returns the last cons (not the last element!) of list. If list is (), it returns ().

EXAMPLES:

(setq x '(a b c d))

(last x) => (d)

(rplacd (last x) '(e f))

x => '(a b c d e f)

(last '(a b c . d)) => (c . d)

 

LISP: LCM

C: Llcm

min args: 1

max args: -1

[F][CLTL 12]

SYNOPSIS:

lcm integer &rest more-integers

DESCRIPTION:

This returns the least common multiple of its arguments, which must be integers. The result of lcm is always a non-negative integer. For two arguments that are not both zero,

(lcm a b) == (/ (abs (* a b)) (gcd a b))

If one or both arguments are zero,

(lcm a 0) == (lcm 0 a) == 0

For one argument, lcm returns the absolute value of that argument. For three or more arguments,

(lcm a b c ... z) == (lcm (lcm a b) c ... z)

EXAMPLES:

(lcm 14 35) => 70

(lcm 0 5) => 0

(lcm 1 2 3 4 5 6) => 60

NOTES:

In ANSI Common LISP lcm returns 1 if given no arguments. Currently, at least one argument is required.

 

LISP: LDIFF

C: Lldiff

min args: 2

max args: 2

[F][CLTL 15]

SYNOPSIS:

ldiff list sublist

DESCRIPTION:

list should be a list, and sublist should be a sublist of list, that is, one of the conses that make up list. ldiff (meaning "list difference") will return a new (freshly consed) list, whose elements are those elements of list that appear before sublist. If sublist is not a tail of list (and in particular if sublist is nil), then a copy of the entire list is returned. The argument list is not destroyed.

EXAMPLES:

(setq x '(a b c d e))

(setq y (cdddr x)) => (d e)

(ldiff x y) => (a b c)

but

(ldiff '(a b c d) '(c d)) => (a b c d)

since the sublist was not eq to any part of the list.

 

LISP: LENGTH

C: Llength

min args: 1

max args: 1

[F][CLTL 14]

SYNOPSIS:

length sequence

DESCRIPTION:

The number of elements in sequence is returned as a non-negative integer. If the sequence is a vector with a fill pointer, the "active length" as specified by the fill pointer is returned.

 

LISP: LET

C: ELet

[S][CLTL 7]

SYNOPSIS:

let ({var | (var value)}*) {declaration}* {form}*

DESCRIPTION:

A let form can be used to execute a series of forms with specified variables bound to specified values.

More precisely, the form

(let ((var1 value1)

(var2 value2)

...

(varm valuem))

declaration1

declaration2

...

declarationp

body1

body2

...

bodyn)

first evaluates the expressions value1, value2, and so on, in that order, saving the resulting values. Then all of the variables varj are bound to the corresponding values in parallel; each binding will be a lexical binding unless there is a special declaration to the contrary. The expressions bodyk are then evaluated in order; the values of all but the last are discarded (that is, the body of a let form is an implicit progn). The let form returns what evaluating bodyn produces (if the body is empty, which is fairly useless, let returns nil as its value). The bindings of the variables have lexical scope and indefinite extent.

Instead of a list (varj valuej), one may write simply varj. In this case varj is initialized to nil. As a matter of style, it is recommended that varj be written only when that variable will be stored into (such as by setq) before its first use. If it is important that the initial value is nil rather than some undefined value, then it is clearer to write out (varj nil) if the initial value is intended to mean "false" or (varj '()) if the initial value is intended to be an empty list. Note that the code

(let (x)

(declare (integer x))

(setq x (gcd y z))

...)

is incorrect; although x is indeed set before it is used, and is set to a value of the declared type integer, nevertheless x momentarily takes on the value nil in violation of the type declaration.

Declarations may appear at the beginning of the body of a let. See declare.

 

LISP: LET*

C: ELets

[S][CLTL 7]

SYNOPSIS:

let* ({var | (var value)}*) {declaration}* {form}*

let* is similar to let, but the bindings of variables are performed sequentially rather than in parallel. This allows the expression for the value of a variable to refer to variables previously bound in the let* form.

More precisely, the form

(let* ((var1 value1)

(var2 value2)

...

(varm valuem))

declaration1

declaration2

...

declarationp

body1

body2

...

bodyn)

first evaluates the expression value1, then binds the variable var1 to that value; then it evaluates value2 and binds var2; and so on. The expressions bodyj are then evaluated in order; the values of all but the last are discarded (that is, the body of a let* form is an implicit progn). The let* form returns the result of evaluating bodyn (if the body is empty, which is fairly useless, let* returns nil as its value). The bindings of the variables have lexical scope and indefinite extent.

Instead of a list (varj valuej), one may write simply varj. In this case varj is initialized to nil. As a matter of style, it is recommended that varj be written only when that variable will be stored into (such as by setq) before its first use. If it is important that the initial value is nil rather than some undefined value, then it is clearer to write out (varj nil) if the initial value is intended to mean "false" or (varj '()) if the initial value is intended to be an empty list.

Declarations may appear at the beginning of the body of a let*.

SEE ALSO:

let, declare

 

LISP: LISP-IMPLEMENTATION-TYPE

min args: 0

max args: 0

[F][CLTL 25]

SYNOPSIS:

lisp-implementation-type

DESCRIPTION:

A string is returned that identifies the generic name of the particular Common LISP implementation.

NOTES:

This function is defined in init0.lsp.

 

LISP: LISP-IMPLEMENTATION-VERSION

min args: 0

max args: 0

[F][CLTL 25]

SYNOPSIS:

lisp-implementation-version

DESCRIPTION:

A string is returned that identifies the version of the particular Common LISP implementation; this information should be of use to maintainers of the implementation.

NOTES:

This function is defined in init0.lsp.

 

LISP: LIST

C: Llist

min args: 0

max args: -1

[F][CLTL 15]

SYNOPSIS:

list &rest args

DESCRIPTION:

list constructs and returns a list of its arguments.

EXAMPLE:

(list 3 4 'a (car '(b . c)) (+ 6 -2)) => (3 4 a b 4)

 

LISP: LIST (typespec)

[Typespec][CLTL 4]

SYNOPSIS:

list

DESCRIPTION:

This is the type specifier symbol which indicates the union of the set of cons objects and the empty list nil.

EXAMPLES:

(typep '(a b c) 'list) => t

(typep 3 'list) => nil

(typep '()) 'list) => t

; but

(typep '() 'cons) => nil

See Also:

list (the function)

 

LISP: LIST*

C: Lliststar

min args: 1

max args: -1

[F][CLTL 15]

SYNOPSIS:

list* arg &rest others

DESCRIPTION:

list* is like list except that the last cons of the constructed list is "dotted." The last argument to list* is used as the cdr of the last cons constructed; this need not be an atom. If it is not an atom, then the effect is to add several new elements to the front of a list.

EXAMPLES:

(list* 'a 'b 'c 'd) => (a b c . d)

This is like

(cons 'a (cons 'b (cons 'c 'd)))

Also:

(list* 'a 'b 'c '(d e f)) => (a b c d e f)

(list* x) == x

 

LISP: LIST-ALL-PACKAGES

C: LsAllPkg

min args: 0

max args: 0

[F][CLTL]

SYNOPSIS:

list-all-packages

DESCRIPTION:

This function returns a list of all packages that currently exist in the LISP system.

 

LISP: LIST-LENGTH

C: Llist_length

min args: 1

max args: 1

[F][CLTL 15]

SYNOPSIS:

list-length list

DESCRIPTION:

list-length returns, as an integer, the length of list. list-length differs from length when the list is circular; length may fail to return, whereas list-length will return nil.

EXAMPLE:

(list-length '()) => 0

(list-length '(a b c d)) => 4

(list-length '(a (b c) d)) => 3

(let ((x (list 'a b c)))

rplacd (last x) x)

list-length x)) => nil

NOTES:

list-length is implemented using the following algorithm:

(defun list-length (x)

(do ((n 0 (+ n 2)) ;Counter.

(fast x (cddr fast)) ;Fast pointer: leaps by 2.

(slow x (cdr slow))) ;Slow pointer: leaps by 1.

(nil)

;; If fast pointer hits the end, return the count.

(when (endp fast) (return n))

(when endp (cdr fast)) (return (+ n 1)))

;; If fast pointer eventually equals slow pointer,

;; then we must be stuck in a circular list.

;; (A deeper property is the converse: if we are

;; stuck in a circular list, then eventually the

;; fast pointer will equal the slow pointer.

;; That fact justifies this implementation.)

(when (and (eq fast slow) (> n 0)) (return nil))))

See length, which will return the length of any sequence.

 

LISP: LISTDEFS

C: Llistdefs

min args: 0

max args: 0

[F][SSCL]

SYNOPSIS:

listdefs

DESCRIPTION:

The Star Sapphire listdefs function returns a list of all functions in the user package with user-supplied functional definitions. Therefore, this is the easiest way to determine a list of all established defuns.

 

LISP: LISTEN

C: Llisten

min args: 0

max args: 1

[F][CLTL 22]

SYNOPSIS:

listen &optional stream

DESCRIPTION:

The listen predicate returns t if there is one or more keystrokes pending in the keyboard input queue and nil otherwise.

These keystrokes can be flushed using clear-input.

NOTES:

The optional stream argument is accepted for compatibility but ignored. This function is equivalent to the C kbhit() function.

EXAMPLE:

Here is one reliable way to loop until a key is pressed:

(format t "press any key to stop demo~%")

(if (listen)(clear-input)) ; clear any existing keystrokes

(loop

(if (listen) (return))

; your demo here

)

 

LISP: LISTP

C: Llistp

min args: 1

max args: 1

[F][SSCL 6]

SYNOPSIS:

listp object

DESCRIPTION:

listp is true if its argument is a cons or the empty list (), and otherwise is false. It does not check for whether the list is a "true list" (one terminated by nil) or a "dotted list" (one terminated by a non-null atom).

(listp x) == (typep x 'list) == (typep x '(or cons null))

NOTES:

Novices take note: The consp function is more restrictive; it does not return t for the empty list.

 

LISP: LOAD

C: L_Load

min args: 1

max args: -1

[F][CLTL 23]

SYNOPSIS:

load filename &key :verbose :print :if-does-not-exist

DESCRIPTION:

This function loads the file named by filename into the LISP environment.

To load a file means to read through the file, evaluating each form in it. Programs are typically stored in files; the expressions in the file are mostly special forms such as defun, defmacro, and defvar, which define the functions and variables of the program.

The Star Sapphire load function transparently loads fastload files (produced by compile-file). Thus, the filename may also specify a fastload file; such files are detected by inspecting the first few bytes for a standard header.

If the first argument is a stream rather than a pathname, then load determines what kind of stream it is and loads directly from the stream.

The :verbose argument (which defaults to the value of *load-verbose*), if true, permits load to print a message in the form of a comment (that is, with a leading semicolon) to *standard-output*. If a binary fine is being loaded, then what is printed may not reflect precisely the contents of the source file, but nevertheless some information will be printed.

If a file is successfully loaded, load always returns a non-nil value. If :if-does-not-exist is specified and is nil, load just returns nil rather than signalling an error if the file does not exist.

 

LISP: LOG

C: Llog

min args: 1

max args: 2

[F][CLTL 12]

SYNOPSIS:

log number &optional base

DESCRIPTION:

Returns the logarithm of number in the base base, which defaults to e, the base of the natural logarithms.

NOTES:

The only current legal value for base is 10.

 

LISP: LOGAND

C: Llogand

min args: 0

max args: -1

[F][CLTL 12]

SYNOPSIS:

logand &rest integers

DESCRIPTION:

This returns the bit-wise logical and of its arguments. If no argument is given, then the result is -1, which is an identity for this operation.

 

LISP: LOGANDC1

C: llogandc1

min args: 2

max args: 2

[F][CLTL 12]

SYNOPSIS:

logandc1 integer1 integer2

DESCRIPTION:

This function negates its first argument and then performs the logical and operation on the result and the second argument.

(logandc1 n1 n2) == (logand (lognot n1) n2)

 

LISP: LOGANDC2

C: llogandc2

min args: 2

max args: 2

[F][CLTL 12]

SYNOPSIS:

logandc2 integer1 integer2

DESCRIPTION:

This function performs the logical and operation on its first argument and the result of negating its second argument.

(logandc2 n1 n2) == (logand n1 (lognot n2))

 

LISP: LOGBITP

C: llogbitp

min args: 2

max args: 2

[F][CLTL 12]

SYNOPSIS:

logbitp index integer

DESCRIPTION:

logbitp is true if the bit in integer whose index is index (that is, its weight is 2index) is a one-bit; otherwise it is false . For example:

(logbitp 2 6) is true

(logbitp 0 6) is false

(logbitp k n) == (ldb-test (byte 1 k) n)

 

LISP: LOGCOUNT

C: Llogcount

min args: 1

max args: 1

[F][CLTL 12]

SYNOPSIS:

logcount integer

DESCRIPTION:

The number of bits in the integer argument is counted and returned. If integer is positive, then 1 bits in its binary representation are counted. If integer is negative, then the 0 bits in its two's-complement binary representation are counted. The result is always a non-negative integer.

EXAMPLES:

(logcount 13) => 3 ;Binary representation is ...0001101

(logcount -13) => 2 ;Binary representation is ...1110011

(logcount 30) => 4 ;Binary representation is ...0011110

(logcount -30) => 4 ;Binary representation is ...1100010

The following identity always holds:

(logcount x) == (logcount (- (+ x 1)))

== (logcount (lognot x))

 

LISP: LOGEQV

C: llogeqv

min args: 0

max args: -1

[F][CLTL 12]

SYNOPSIS:

logeqv &rest integers

DESCRIPTION:

This returns the bit-wise logical equivalence (also known as exclusive nor) of its arguments. If no argument is given, then the result is -1, which is an identity for this operation.

 

LISP: LOGIOR

C: Llogior

min args: 0

max args: -1

[F][CLTL 12]

SYNOPSIS:

logior &rest integers

DESCRIPTION:

This returns the bit-wise logical inclusive or of its arguments. If no argument is given, then the result is zero, which is an identity for this operation.

 

LISP: LOGNAND

C: llognand

min args: 2

max args: 2

[F][CLTL 12]

SYNOPSIS:

lognand integer1 integer2

DESCRIPTION:

This function performs a logical nand operation on its integer arguments.

(lognand n1 n2) == (lognot (logand n1 n2))

 

LISP: LOGNOR

C: llognor

min args: 2

max args: 2

[F][CLTL 12]

SYNOPSIS:

lognor integer1 integer2

DESCRIPTION:

This function performs a logical nor operation on its integer arguments.

(lognor n1 n2) == (lognot (logior n1 n2))

 

LISP: LOGNOT

C: llognot

min args: 1

max args: 1

[F][CLTL 12]

SYNOPSIS:

lognot integer

DESCRIPTION:

This returns the bit-wise logical not of its argument . Every bit of the result is the complement of the corresponding bit in the argument.

(logbitp j (lognot x)) == (not (logbitp j x))

 

LISP: LOGORC1

C: llogorc1

min args: 2

max args: 2

[F][CLTL 12]

SYNOPSIS:

logorc1 integer1 integer2

DESCRIPTION:

This function negates its first argument and then performs the logical inclusive or operation on the result and the second argument.

(logiorc1 n1 n2) == (logior (lognot n1) n2)

 

LISP: LOGORC2

C: llogorc2

min args: 2

max args: 2

[F][CLTL 12]

SYNOPSIS:

logorc2 integer1 integer2

DESCRIPTION:

This function performs the logical inclusive or operation on its first argument and the result of negating its second argument.

(logiorc2 n1 n2) == (logior nl (lognot n2))

 

LISP: LOGTEST

C: llogtest

min args: 2

max args: 2

[F][CLTL 12]

SYNOPSIS:

logtest integer1 integer2

DESCRIPTION:

logtest is a predicate that is true if any of the bits designated by the 1's in integer1 are 1's in integer2.

(logtest x y) == (not (zerop (logand x y)))

 

LISP: LOGXOR

C: Llogxor

min args: 0

max args: -1

[F][CLTL 12]

SYNOPSIS:

logxor &rest integers

DESCRIPTION:

This returns the bit-wise logical exclusive or of its arguments. If no argument is given, then the result is zero, which is an identity for this operation.

 

LISP: LOOP

C: SFCLoop, ELoop

[M][CLTL 7]

SYNOPSIS:

loop {form}*

DESCRIPTION:

Each form is evaluated in turn from left to right. When the last form has been evaluated, then the first form is evaluated again, and so on, in a never-ending cycle. The loop construct never returns a value. Its execution must be terminated explicitly, using return or throw, for example.

loop, like most iteration constructs, establishes an implicit block named nil. Thus return may be used to exit from a loop with specified results.

 

LISP: LONG-FLOAT

[Typespec][CLTL 4]

SYNOPSIS:

long-float [[low] high]

long-float

DESCRIPTION:

This is the type specifier symbol which indicates the set of long floating point numbers. Objects of this type are a subtype of the type float.

This specifier can occur either as a symbol or at the head of a type specifier list. In the latter case, optional low and high values can be specified. The low and high values can be specified as

a floating point number, indicating an inclusive limit

a list of exactly one floating point number, indicating an exclusive limit

or left unspecified either explicitly by writing * or by omission. If the limit is unspecified it is considered to be negative or positive infinity, for the low and high values respectively.

NOTES:

In this implementaion, there is only one size of floating point number, so use of long-float is equivalent to the use of float.

 

LISP: LONG-SITE-NAME

min args: 0

max args: 0

[F][CLTL 25]

SYNOPSIS:

long-site-name

DESCRIPTION:

A string is returned that verbosely identifies the physical location of the computer hardware.

SEE ALSO:

short-site-name

NOTES:

This function is defined in init0.lsp.

 

LISP: LOWER-CASE-P

C: LLoCCharP

min args: 1

max args: 1

[F][CLTL 13]

SYNOPSIS:

lower-case-p char

DESCRIPTION:

The argument char must be a character object.

lower-case-p is true if the argument is a lower-case character, and otherwise is false.

Of the standard characters (as defined by standard-char-p), the letters a through z are lower-case.

If a character is lower-case, it is necessarily alphabetic (and therefore also graphic).