7.5.2 GMap Base Result Types

GMap result type: list &key filterp

Returns a list of the values, optionally filtered by filterp (which can be :id to filter out nil).

GMap result type: alist &key filterp

Consumes two values from the mapped function; returns an alist of the pairs. filterp, if supplied, must take two arguments.

GMap result type: plist &key filterp

Consumes two values from the mapped function; returns a plist of the pairs. filterp, if supplied, must take two arguments.

GMap result type: hash-table &key test size rehash-size rehash-threshold filterp

Consumes two values from the mapped function; returns a hash-table of the pairs. If any of test, size, rehash-size, or rehash-threshold are supplied, they are passed to make-hash-table. filterp, if supplied, must take two arguments.

GMap result type: append &key filterp

Returns the result of appending the values, optionally filtered by filterp (which can be :id to filter out nil).

GMap result type: nconc &key filterp

Returns the result of nconcing the values, optionally filtered by filterp (which can be :id to filter out nil).

GMap result type: and

If one of the values is false, terminates the iteration and returns false; otherwise returns the last value. Does not work as an operand of values. (Generalizes cl:every.)

GMap result type: or

If one of the values is true, terminates the iteration and returns it; otherwise, returns false. (Does not work as an operand of values. (Generalizes cl:some.)

GMap result type: sum &key filterp

Returns the sum of the values, optionally filtered by filterp (which can be :id to filter out nil).

GMap result type: product &key filterp

Returns the product of the values, optionally filtered by filterp (which can be :id to filter out nil).

GMap result type: count

Returns the number of true values.

GMap result type: max &key filterp key

Optionally filters the values by filterp, then returns the maximum, or if key is supplied, the value with the maximum key (if that’s not unique, returns the first one); or nil if no values were supplied (or survived filtering). Example:

(gmap (:result max :key #'cdr) nil (:arg list alist))

returns the (first) pair of alist with the maximum cdr.

If key is :second-value, the second value of the mapped function is used; for example,

(gmap (:result max :key :second-value) nil (:arg alist an-alist))

returns the (first) car of an-alist with the maximum corresponding cdr.

GMap result type: min &key filterp key

Optionally filters the values by filterp, then returns the minimum, or if key is supplied, the value with the minimum key (if that’s not unique, returns the first one); or nil if no values were supplied (or survived filtering). Example:

(gmap (:result min :key #'cdr) nil (:arg list alist))

returns the (first) pair of alist with the minimum cdr.

If key is :second-value, the second value of the mapped function is used; for example,

(gmap (:result min :key :second-value) nil (:arg alist an-alist))

returns the (first) car of an-alist with the minimum corresponding cdr.

GMap result type: vector &key use-vector length fill-pointer adjustable filterp

Constructs a vector containing the results. If use-vector is supplied, the argument will be filled with the results and returned; if fill-pointer is true and adjustable is true, it must have a fill pointer and be adjustable, and values will be appended to it with vector-push-extend; if fill-pointer is true and adjustable is false, it must have a fill pointer, and values will be appended to it with vector-push; otherwise, the vector is assumed to be simple and must be large enough to hold the results. (Recall that vector-push has no effect if the vector is full.)

If use-vector is not supplied, a vector will be constructed and returned; if length is supplied, returns a simple vector of the specified length (which must be sufficient to hold the results); otherwise, returns a simple vector of the correct length (but to do this, it must cons a temporary list).

In any case, if filterp is supplied, it is a predicate of one argument, the value of the function being mapped, that says whether to include it in the result (filterp can be :id to filter out nil).

GMap result type: string &key use-string length fill-pointer adjustable filterp

Constructs a string containing the results. If use-string is supplied, the argument will be filled with the results and returned; if fill-pointer is true and adjustable is true, it must have a fill pointer and be adjustable, and values will be appended to it with vector-push-extend; if fill-pointer is true and adjustable is false, it must have a fill pointer, and values will be appended to it with vector-push; otherwise, the vector is assumed to be simple and must be large enough to hold the results. (Recall that vector-push has no effect if the vector is full.)

If use-string is not supplied, a string will be constructed and returned; if length is supplied, returns a simple string of the specified length (which must be sufficient to hold the results); otherwise, returns a simple string of the correct length (but to do this, it must cons a temporary list).

In any case, if filterp is supplied, it is a predicate of one argument, the value of the function being mapped, that says whether to include it in the result (filterp can be :id to filter out nil).

GMap result type: array dims &key element-type initial-element filterp

Constructs an array containing the results. Passes dims, and element-type and initial-element if supplied, to make-array. If the array is multidimensional, fills it in row-major order.