Star Sapphire Common LISP Home

Download Star Saphire
Index

LISP: VALUES

C: LValues

min args: -1

max args: -1

[F][CLTL 7]

SYNOPSIS:

values &rest args

DESCRIPTION:

All of the arguments are returned, in order, as values.

The expression (values) returns zero values. This is the standard idiom for returning no values from a function.

Sometimes it is desirable to indicate explicitly that a function will return exactly one value. For example, the function

(defun foo (x y)

(floor (+ x y) y))

will return two values because floor returns two values. It may be that the second value makes no sense. The values function is the standard idiom for indicating that only one value is to be returned, as shown in the following example.

(defun foo (x y)

(values (floor (+ x y) y)))

This works because values returns exactly one value for each of its argument forms; as for any function call, if any argument form to values produces more than one value, all but the first are discarded.

There is absolutely no way in Common LISP for a caller to distinguish between returning a single value in the ordinary manner and returning exactly one multiple value. For example, the values returned by the expressions (+ 1 2) and (values (+ 1 2)) are identical in every respect: The single value 3.

 

LISP: VALUES-LIST

C: ValuesLs

min args: 1

max args: 1

[F][CLTL 7]

SYNOPSIS:

values-list list

DESCRIPTION:

All of the elements of list' are returned as multiple values. Essentially:

(values-list (list x y z)) == (values x y z)

NOTES:

(values-list) == (apply #'values list)

but values-list may be clearer and more efficient.

 

LISP: VECTOR

C: Lvector

min args: 0

max args: -1

[F][CLTL 17]

SYNOPSIS:

vector &rest objects

DESCRIPTION:

The function vector is a convenient means for creating a simple general vector with specified initial contents. It is analogous to the function list but for vectors.

(vector a1 a2 ... an)

== (make-array (list n) :element-type t

:initial-contents (list a1 a2 ... an))

See Also:

vector (typespec), make-array

 

LISP: VECTOR (typespec)

min args: 0

max args: 1

[Typespec][CLTL 4]

SYNOPSIS:

vector [size]

vector

DESCRIPTION:

This is the type specifier which represents vectors. Vectors are one dimensional arrays.

The symbol can be used by itself or as the car of a type specifier list.

When used in a type specifier list, an optional size for the vector can be specified. The size can be unspecified either by omission or *'

SEE ALSO:

vector, simple-array, vectorp, simple-vector

 

LISP: VECTOR-POP

C: LVecPop

min args: 1

max args: 1

[F][CLTL 17]

SYNOPSIS:

vector-pop vector

DESCRIPTION:

The argument must be a one-dimensional array that has a fill pointer. If the fill pointer is zero, vector-pop signals an error. Otherwise the fill pointer is decreased by one, and the vector element designated by the new value of the fill pointer is returned.

 

LISP: VECTOR-PUSH

C: LVecPush

min args: 2

max args: 2

[F][CLTL 17]

SYNOPSIS:

vector-push new-element vector

DESCRIPTION:

The vector argument must be a one-dimensional array that has a fill pointer, and new-element may be any object. vector-push attempts to store new-element in the element of the vector designated by the fill pointer, and to increase the fill pointer by one.

If the fill pointer does not designate an element of vector (specifically, when it gets too big), it is unaffected and vector-push returns nil. Otherwise, the store and increment take place and vector-push returns the former value of the fill pointer (one less than the one it leaves in the vector); thus the value of vector-push is the index of the new element pushed.

 

LISP: VECTORP

C: Lvectorp

min args: 1

max args: 1

[F][CLTL 6]

SYNOPSIS:

vectorp object

DESCRIPTION:

The vectorp predicate is true if its argument is a vector, and otherwise is false.

(vectorp x) == (typep x 'vector)