There are 119 utilities.
- factorial v1.0
-
Compute the factorial of
n
, wheren! = 1 * 2 * ... * n
.- Provides
factorial
- Requires
- range-product
- binomial-coefficient v1.0
-
Binomial coefficient of
n
andk
.- Provides
binomial-coefficient
- Requires
- factorial, range-product
- define-constant v1.0
-
Ensures that the global variable named by
name
is a constant with a value that is equal undertest
to the result of evaluatinginitial-value
.test
is a function designator that defaults toeql
. Ifdocumentation
is given, it becomes the documentation string of the constant.Signals an error if
name
is already a bound non-constant variable.Signals an error if
name
is already a constant variable whose value is not equal undertest
to result of evaluatinginitial-value
.- Provides
define-constant
- if-let v1.0
-
Creates new variable bindings, and conditionally executes either
then-form
orelse-form
.else-form
defaults tonil
.bindings
must be either single binding of the form:(variable initial-form)
or a list of bindings of the form:
((variable-1 initial-form-1) (variable-2 initial-form-2) ... (variable-n initial-form-n))
All initial-forms are executed sequentially in the specified order. Then all the variables are bound to the corresponding values.
If all variables were bound to true values, the
then-form
is executed with the bindings in effect, otherwise theelse-form
is executed with the bindings in effect.- Provides
if-let
- when-let v1.0
-
Creates new variable bindings, and conditionally executes a series of forms.
- Provides
when-let
,when-let*
- string-designator v1.0
-
A string designator type. A string designator is either a string, a symbol, or a character.
- Provides
string-designator
- required-argument v1.0
-
Signals an error for a missing argument of
name
. Intended for use as an initialization form for structure and class-slots, and a default value for required keyword arguments.- Provides
required-argument
- simple-style-warning v1.0
-
- Provides
simple-style-warning
- simple-reader-error v1.0
-
- Provides
simple-reader-error
- simple-parse-error v1.0
-
- Provides
simple-parse-error
- simple-program-error v1.0
-
- Provides
simple-program-error
- ignore-some-conditions v1.0
-
Similar to
cl:ignore-errors
but the (unevaluated)conditions
list determines which specific conditions are to be ignored.- Provides
ignore-some-conditions
- unwind-protect-case v1.0
-
Like
cl:unwind-protect
, but you can specify the circumstances that the cleanupclauses
are run.clauses ::= (:NORMAL form*)* | (:ABORT form*)* | (:ALWAYS form*)*
Clauses can be given in any order, and more than one clause can be given for each circumstance. The clauses whose denoted circumstance occured, are executed in the order the clauses appear.
abort-flag
is the name of a variable that will be bound tot
inclauses
if theprotected-form
aborted preemptively, and tonil
otherwise.Examples:
(unwind-protect-case () (protected-form) (:normal (format t "This is only evaluated if PROTECTED-FORM executed normally.~%")) (:abort (format t "This is only evaluated if PROTECTED-FORM aborted preemptively.~%")) (:always (format t "This is evaluated in either case.~%"))) (unwind-protect-case (aborted-p) (protected-form) (:always (perform-cleanup-if aborted-p)))
- Provides
unwind-protect-case
- copy-hash-table v1.0
-
Returns a copy of hash table
table
, with the same keys and values as thetable
. The copy has the same properties as the original, unless overridden by the keyword arguments.Before each of the original values is set into the new hash-table,
key
is invoked on the value. Askey
defaults tocl:identity
, a shallow copy is returned by default.- Provides
copy-hash-table
- maphash-keys v1.0
-
Like
maphash
, but callsfunction
with each key in the hash tabletable
.- Provides
maphash-keys
- maphash-values v1.0
-
Like
maphash
, but callsfunction
with each value in the hash tabletable
.- Provides
maphash-values
- hash-table-keys v1.0
-
Returns a list containing the keys of hash table
table
.- Provides
hash-table-keys
- Requires
- maphash-keys
- hash-table-values v1.0
-
Returns a list containing the values of hash table
table
.- Provides
hash-table-values
- Requires
- maphash-values
- hash-table-alist v1.0
-
Returns an association list containing the keys and values of hash table
table
.- Provides
hash-table-alist
- hash-table-plist v1.0
-
Returns a property list containing the keys and values of hash table
table
.- Provides
hash-table-plist
- alist-hash-table v1.0
-
Returns a hash table containing the keys and values of the association list
alist
. Hash table is initialized using thehash-table-initargs
.- Provides
alist-hash-table
- plist-hash-table v1.0
-
Returns a hash table containing the keys and values of the property list
plist
. Hash table is initialized using thehash-table-initargs
.- Provides
plist-hash-table
- ensure-gethash v1.0
-
Like
gethash
, but ifkey
is not found in thehash-table
saves thedefault
under key before returning it. Secondary return value is true if key was already in the table.- Provides
ensure-gethash
- ensure-symbol v1.0
-
Returns a symbol with name designated by
name
, accessible in package designated bypackage
. If symbol is not already accessible inpackage
, it is interned there. Returns a secondary value reflecting the status of the symbol in the package, which matches the secondary return value ofintern
.Example:
(ensure-symbol :cons :cl) => cl:cons, :external
- Provides
ensure-symbol
- format-symbol v1.0
-
Constructs a string by applying
arguments
to string designatorcontrol
as if byformat
withinwith-standard-io-syntax
, and then creates a symbol named by that string.If
package
isnil
, returns an uninterned symbol, if package ist
, returns a symbol interned in the current package, and otherwise returns a symbol interned in the package designated bypackage
.- Provides
format-symbol
- make-keyword v1.0
-
Interns the string designated by
name
in thekeyword
package.- Provides
make-keyword
- make-gensym v1.0
-
If
name
is a non-negative integer, callsgensym
using it. Otherwisename
must be a string designator, in which case callsgensym
using the designated string as the argument.- Provides
make-gensym
- make-gensym-list v1.0
-
Returns a list of
length
gensyms, each generated as if with a call tomake-gensym
, using the second (optional, defaulting to"G"
) argument.- Provides
make-gensym-list
- symbolicate v1.0
-
Concatenate together the names of some strings and symbols, producing a symbol in the current package.
- Provides
symbolicate
- with-gensyms v1.0
-
Binds each variable named by a symbol in
names
to a unique symbol aroundforms
. Each ofnames
must either be either a symbol, or of the form:(symbol string-designator)
Bare symbols appearing in
names
are equivalent to:(symbol symbol)
The string-designator is used as the argument to
gensym
when constructing the unique symbol the named variable will be bound to.- Provides
with-gensyms
,with-unique-names
- Requires
- string-designator
- once-only v1.0
-
Evaluates
forms
with symbols specified inspecs
rebound to temporary variables, ensuring that each initform is evaluated only once.Each of
specs
must either be a symbol naming the variable to be rebound, or of the form:(symbol initform)
Bare symbols in
specs
are equivalent to(symbol symbol)
Example:
(defmacro cons1 (x) (once-only (x) `(cons ,x ,x))) (let ((y 0)) (cons1 (incf y))) => (1 . 1)
- Provides
once-only
- Requires
- make-gensym-list
- parse-body v1.0
-
Parses
body
into(values remaining-forms declarations doc-string)
. Documentation strings are recognized only ifdocumentation
is true. Syntax errors in body are signalled andwhole
is used in the signal arguments when given.- Provides
parse-body
- parse-ordinary-lambda-list v1.0
-
Parses an ordinary lambda-list, returning as multiple values:
Required parameters.
Optional parameter specifications, normalized into form:
(name init suppliedp)
Name of the rest parameter, or
nil
.Keyword parameter specifications, normalized into form:
((keyword-name name) init suppliedp)
Boolean indicating
&allow-other-keys
presence.&aux
parameter specifications, normalized into form
(name init)
.- Existence of
&key
in thelambda-list
.
Signals a
program-error
iflambda-list
is malformed.- Provides
parse-ordinary-lambda-list
- Requires
- simple-program-error, ensure-list, make-keyword
- destructuring-case v1.0
-
destructuring-case
, 'destructuring-ccaseand 'destructuring-ecase
are a combination ofcase
anddestructuring-bind
.keyform
must evaluate to afcons
.Clauses are of the form:
((case-keys . destructuring-lambda-list) form*)
The clause whose
case-keys
matchescar
ofkey
, as if bycase
,ccase
, orecase
, is selected, andform
s are then executed withcdr
ofkey
is destructured and Bound By Thedestructuring-lambda-list
.Example:
(defun dcase (x) (destructuring-case x ((:foo a b) (format nil "foo: ~S, ~S" a b)) ((:bar &key a b) (format nil "bar, ~S, ~S" a b)) (((:alt1 :alt2) a) (format nil "alt: ~S" a)) ((t &rest rest) (format nil "unknown: ~S" rest)))) (dcase (list :foo 1 2)) ; => "foo: 1, 2" (dcase (list :bar :a 1 :b 2)) ; => "bar: 1, 2" (dcase (list :alt1 1)) ; => "alt: 1" (dcase (list :alt2 2)) ; => "alt: 2" (dcase (list :quux 1 2 3)) ; => "unknown: 1, 2, 3" (defun decase (x) (destructuring-case x ((:foo a b) (format nil "foo: ~S, ~S" a b)) ((:bar &key a b) (format nil "bar, ~S, ~S" a b)) (((:alt1 :alt2) a) (format nil "alt: ~S" a)))) (decase (list :foo 1 2)) ; => "foo: 1, 2" (decase (list :bar :a 1 :b 2)) ; => "bar: 1, 2" (decase (list :alt1 1)) ; => "alt: 1" (decase (list :alt2 2)) ; => "alt: 2" (decase (list :quux 1 2 3)) ; =| error
- Provides
destructuring-case
,destructuring-ccase
,destructuring-ecase
- Requires
- once-only
- extract-function-name v1.0
-
Useful for macros that want to mimic the functional interface for functions like
#'eq
and'eq
.- Provides
extract-function-name
- switch v1.0
-
Dispatch to different branches of code based off of the value of an expression.
- Provides
switch
,eswitch
,cswitch
- Requires
- with-gensyms, extract-function-name
- whichever v1.0
-
Evaluates exactly one of
possibilities
, chosen at random.- Provides
whichever
- Requires
- with-gensyms
- xor v1.0
-
Evaluates its arguments one at a time, from left to right. If more then one argument evaluates to a true value no further
datums
are evaluated, andnil
is returned as both primary and secondary value. If exactly one argument evaluates to true, its value is returned as the primary value after all the arguments have been evaluated, andt
is returned as the secondary value. If no arguments evaluate to truenil
is retuned as primary, andt
as secondary value.- Provides
xor
- Requires
- with-gensyms
- nth-value-or v1.0
-
Evaluates
form
arguments one at a time, until thenth-value
returned by one of the forms is true. It then returns all the values returned by evaluating that form. If none of the forms return a true nth value, this form returnsnil
.- Provides
nth-value-or
- Requires
- with-gensyms, once-only
- multiple-value-prog2 v1.0
-
Evaluates
first-form
, thensecond-form
, and thenforms
. Yields as its value all the value returned bysecond-form
.- Provides
multiple-value-prog2
- featurep v1.0
-
Returns
t
if the argument matches the state of the*features*
list andnil
if it does not.feature-expression
can be any atom or list acceptable to the reader macros#+
and#-
.- Provides
featurep
- Requires
- switch
- ensure-function v1.0
-
Returns the function designated by
function-designator
: iffunction-designator
is a function, it is returned, otherwise it must be a function name and itsfdefinition
is returned.- Provides
ensure-function
- ensure-functionf v1.0
-
Multiple-place modify macro for
ensure-function
: ensures that each ofplaces
contains a function.- Provides
ensure-functionf
- Requires
- ensure-function
- disjoin v1.0
-
Returns a function that applies each of
predicate
andmore-predicate
functions in turn to its arguments, returning the primary value of the first predicate that returns true, without calling the remaining predicates. If none of the predicates returns true,nil
is returned.- Provides
disjoin
- Requires
- ensure-function
- conjoin v1.0
-
Returns a function that applies each of
predicate
andmore-predicate
functions in turn to its arguments, returningnil
if any of the predicates returns false, without calling the remaining predicates. If none of the predicates returns false, returns the primary value of the last predicate.- Provides
conjoin
- compose v1.0
-
Returns a function composed of
function
andmore-functions
that applies its ; arguments to to each in turn, starting from the rightmost ofmore-functions
, and then calling the next one with the primary value of the last.- Provides
compose
- Requires
- make-gensym-list, ensure-function
- multiple-value-compose v1.0
-
Returns a function composed of
function
andmore-functions
that applies its arguments to each in turn, starting from the rightmost ofmore-functions
, and then calling the next one with all the return values of the last.- Provides
multiple-value-compose
- Requires
- make-gensym-list, ensure-function
- curry v1.0
-
Returns a function that applies
arguments
and the arguments it is called with tofunction
.- Provides
curry
- Requires
- make-gensym-list, ensure-function
- rcurry v1.0
-
Returns a function that applies the arguments it is called with and
arguments
tofunction
.- Provides
rcurry
- Requires
- ensure-function
- named-lambda v1.0
-
Expands into a lambda-expression within whose
body
name
denotes the corresponding function.- Provides
named-lambda
- array-bounds v1.0
-
Types related to array bounds.
- Provides
array-index
,array-length
- sub-interval-numeric-types v1.0
-
Contains 'sub-interval numeric types'. Majority of the implementation of CDR5.
- Provides
negative-double-float
,negative-fixnum-p
,negative-float
,negative-float-p
,negative-long-float
,negative-long-float-p
,negative-rational
,negative-rational-p
,negative-real
,negative-single-float-p
,non-negative-double-float
,non-negative-double-float-p
,non-negative-fixnum
,non-negative-fixnum-p
,non-negative-float
,non-negative-float-p
,non-negative-integer-p
,non-negative-long-float
,non-negative-rational
,non-negative-real-p
,non-negative-short-float-p
,non-negative-single-float
,non-negative-single-float-p
,non-positive-double-float
,non-positive-double-float-p
,non-positive-fixnum
,non-positive-fixnum-p
,non-positive-float
,non-positive-float-p
,non-positive-integer
,non-positive-rational
,non-positive-real
,non-positive-real-p
,non-positive-short-float
,non-positive-short-float-p
,non-positive-single-float-p
,positive-double-float
,positive-double-float-p
,positive-fixnum
,positive-fixnum-p
,positive-float
,positive-float-p
,positive-integer
,positive-rational
,positive-real
,positive-real-p
,positive-short-float
,positive-short-float-p
,positive-single-float
,positive-single-float-p
,negative-double-float-p
,negative-fixnum
,negative-integer
,negative-integer-p
,negative-real-p
,negative-short-float
,negative-short-float-p
,negative-single-float
,non-negative-integer
,non-negative-long-float-p
,non-negative-rational-p
,non-negative-real
,non-negative-short-float
,non-positive-integer-p
,non-positive-long-float
,non-positive-long-float-p
,non-positive-rational-p
,non-positive-single-float
,positive-integer-p
,positive-long-float
,positive-long-float-p
,positive-rational-p
- Requires
- format-symbol
- of-type v1.0
-
Returns a function of one argument, which returns true when its argument is of TYPE.
- Provides
of-type
- Requires
- with-gensyms
- type= v1.0
-
Returns a primary value of
t
istype1
andtype2
are the same type, and a secondary value that is true is the type equality could be reliably determined: primary value ofnil
and secondary value oft
indicates that the types are not equivalent.- Provides
type=
- coercef v1.0
-
Modify-macro for
coerce
.- Provides
coercef
- copy-array v1.0
-
Returns an undisplaced copy of
array
, with samefill-pointer
and adjustability (if any) as the original, unless overridden by the keyword arguments.- Provides
copy-array
- alist-plist v1.0
-
Convert between alists and plists.
- Provides
alist-plist
,plist-alist
- Requires
- safe-endp
- assoc-value v1.0
-
Getters and setters for
assoc
andrassoc
values.- Provides
assoc-value
,rassoc-value
- Requires
- with-gensyms
- doplist v1.0
-
Iterates over elements of
plist
.body
can be preceded by declarations, and is like atagbody
.return
may be used to terminate the iteration early. Ifreturn
is not used, returnsvalues
.- Provides
doplist
- Requires
- parse-body, with-gensyms
- appendf v1.0
-
Modify-macro for
append
. Appendslists
to the place designated by the first argument.- Provides
appendf
- nconcf v1.0
-
Modify-macro for
nconc
. Concatenateslists
to place designated by the first argument.- Provides
nconcf
- unionf v1.0
-
Modify-macro for
union
. Saves the union oflist
and the contents of the place designated by the first argument to the designated place.- Provides
unionf
- nunionf v1.0
-
Modify-macro for
nunion
. Saves the union oflist
and the contents of the place designated by the first argument to the designated place. May modify either argument.- Provides
nunionf
- reversef v1.0
-
Modify-macro for
reverse
. Copies and reverses the list stored in the given place and saves back the result into the place.- Provides
reversef
- nreversef v1.0
-
Modify-macro for
nreverse
. Reverses the list stored in the given place by destructively modifying it and saves back the result into the place.- Provides
nreversef
- circular-list v1.0
-
Creation and detection of circular lists.
- Provides
circular-list
,circular-list-p
,make-circular-list
- circular-tree-p v1.0
-
Returns true if
object
is a circular tree,nil
otherwise.- Provides
circular-tree-p
- proper-list-p v1.0
-
Returns true if
object
is a proper list.- Provides
proper-list-p
- proper-list v1.0
-
Type designator for proper lists. Implemented as a
satisfies
type, hence not recommended for performance intensive use. Main usefulness as a type designator of the expected type in atype-error
.- Provides
proper-list
- Requires
- proper-list-p
- proper-list-length/last-car v1.0
-
Compute the length of a proper list, and the last CAR of a list quickly.
- Provides
proper-list-length
,last-car
- Requires
- circular-list, safe-endp
- ensure-car v1.0
-
If
thing
is acons
, itscar
is returned. Otherwisething
is returned.- Provides
ensure-car
- ensure-cons v1.0
-
If
cons
is a cons, it is returned. Otherwise returns a fresh cons withcons
in the car, andnil
in the cdr.- Provides
ensure-cons
- ensure-list v1.0
-
If
list
is a list, it is returned. Otherwise returns the list designated bylist
.- Provides
ensure-list
- remove-from-plist v1.0
-
Destructive and non-destructive functions to remove items from a plist, as well as associated modify macros.
- Provides
remove-from-plist
,delete-from-plist
,remove-from-plistf
,delete-from-plistf
,sans
- mappend v1.0
-
Applies
function
to respective element(s) of eachlist
, appending all the all the result list to a single list.function
must return a list.- Provides
mappend
- setp v1.0
-
Returns true if
object
is a list that denotes a set,nil
otherwise. A list denotes a set if each element of the list is unique underkey
andtest
.- Provides
setp
- set-equal v1.0
-
Returns true if every element of
list1
matches some element oflist2
and every element oflist2
matches some element oflist1
. Otherwise returns false.- Provides
set-equal
- map-product v1.0
-
Returns a list containing the results of calling
function
with one argument fromlist
, and one from each ofmore-lists
for each combination of arguments. In other words, returns the product oflist
andmore-lists
usingfunction
.Example:
(map-product 'list '(1 2) '(3 4) '(5 6)) => ((1 3 5) (1 3 6) (1 4 5) (1 4 6) (2 3 5) (2 3 6) (2 4 5) (2 4 6))
- Provides
map-product
- Requires
- ensure-function, curry, mappend
- with-open-file* v1.0
-
Just like
with-open-file
, butnil
values in the keyword arguments mean to use the default value specified foropen
.- Provides
with-open-file*
- Requires
- once-only
- with-input-from-file v1.0
-
Evaluate
body
withstream-name
to an input stream on the filefile-name
.args
is sent as is to the call toopen
exceptexternal-format
, which is only sent towith-open-file
when it's notnil
.- Provides
with-input-from-file
- Requires
- with-open-file*
- with-output-to-file v1.0
-
Evaluate
body
withstream-name
to an output stream on the filefile-name
.args
is sent as is to the call toopen
exceptexternal-format
, which is only sent towith-open-file
when it's notnil
.- Provides
with-output-to-file
- Requires
- with-open-file*
- read-file-into-string v1.0
-
Return the contents of the file denoted by
pathname
as a fresh string.The
external-format
parameter will be passed directly towith-open-file
unless it'snil
, which means the system default.- Provides
read-file-into-string
- Requires
- with-input-from-file
- write-string-into-file v1.0
-
Write
string
topathname
.The
external-format
parameter will be passed directly towith-open-file
unless it'snil
, which means the system default.- Provides
write-string-into-file
- Requires
- with-output-to-file
- read-file-into-byte-vector v1.0
-
Read
pathname
into a freshly allocated(unsigned-byte 8)
vector.- Provides
read-file-into-byte-vector
- Requires
- with-input-from-file
- write-byte-vector-into-file v1.0
-
Write
bytes
topathname
.- Provides
write-byte-vector-into-file
- Requires
- with-output-to-file
- copy-file v1.0
-
Copy a file from
from
toto
.- Provides
copy-file
- Requires
- copy-stream, with-output-to-file, with-input-from-file
- copy-stream v1.0
-
Reads data from
input
and writes it tooutput
. Bothinput
andoutput
must be streams, they will be passed toread-sequence
andwrite-sequence
and must have compatibleelement-type
s.- Provides
copy-stream
- Requires
- sub-interval-numeric-types
- sequence-of-length-p v1.0
-
- Provides
sequence-of-length-p
- Requires
- array-bounds
- rotate v1.0
-
Returns a sequence of the same type as
sequence
, with the elements ofsequence
rotated byn
:n
elements are moved from the end of the sequence to the front ifn
is positive, and-n
elements moved from the front to the end ifn
is negative.sequence
must be a proper sequence.n
must be an integer, defaulting to1
.If absolute value of
n
is greater then the length of the sequence, the results are identical to callingrotate
with(* (signum n) (mod n (length sequence))).
Note: the original sequence may be destructively altered, and result sequence may share structure with it.
- Provides
rotate
- Requires
- proper-list-length/last-car
- shuffle v1.0
-
Returns a random permutation of
sequence
bounded bystart
andend
. Original sequece may be destructively modified, and share storage with the original one. Signals an error ifsequence
is not a proper sequence.- Provides
shuffle
- Requires
- proper-list-length/last-car
- random-elt v1.0
-
Returns a random element from
sequence
bounded bystart
andend
. Signals an error if thesequence
is not a proper non-empty sequence, or ifend
andstart
are not proper bounding index designators forsequence
.- Provides
random-elt
- Requires
- proper-list-length/last-car
- removef v1.0
-
Modify-macro for
remove
. Sets place designated by the first argument to the result of callingremove
withitem
, place, and thekeyword-arguments
.- Provides
removef
- deletef v1.0
-
Modify-macro for
delete
. Sets place designated by the first argument to the result of callingdelete
withitem
, place, and thekeyword-arguments
.- Provides
deletef
- proper-sequence v1.0
-
Type designator for proper sequences, that is proper lists and sequences that are not lists.
- Provides
proper-sequence
- Requires
- proper-list
- length= v1.0
-
Takes any number of sequences or integers in any order. Returns true iff the length of all the sequences and the integers are equal.
Hint: there's a compiler macro that expands into more efficient code if the first argument is a literal integer.
- Provides
length=
- Requires
- with-gensyms, sequence-of-length-p, array-bounds
- copy-sequence v1.0
-
Returns a fresh sequence of
type
, which has the same elements assequence
.- Provides
copy-sequence
- first-elt v1.0
-
Getter and setter for the first element of a sequence.
- Provides
first-elt
- Requires
- emptyp
- last-elt v1.0
-
Getter and setter for the last element of a sequence.
- Provides
last-elt
- Requires
- proper-list-length/last-car, emptyp, proper-sequence
- starts-with-subseq v1.0
-
Test whether the first elements of SEQUENCE are the same (as per TEST) as the elements of PREFIX.
If RETURN-SUFFIX is T the functions returns, as a second value, a displaced array pointing to the sequence after PREFIX.
- Provides
starts-with-subseq
- Requires
- remove-from-plist
- ends-with-subseq v1.0
-
Test whether
sequence
ends withsuffix
. In other words: return true if the last(length suffix
) elements ofsequence
are equal tosuffix
.- Provides
ends-with-subseq
- starts-with v1.0
-
Returns true if
sequence
is a sequence whose first element iseql
toobject
. Returnsnil
if thesequence
is not a sequence or is an empty sequence.- Provides
starts-with
- ends-with v1.0
-
Returns true if
sequence
is a sequence whose last element iseql
toobject
. Returnsnil
if thesequence
is not a sequence or is an empty sequence. Signals an error ifsequence
is an improper list.- Provides
ends-with
- Requires
- proper-list-length/last-car
- map-combinations v1.0
-
Calls
function
with each combination oflength
constructable from the elements of the subsequence ofsequence
delimited bystart
andend
.start
defaults to0
,end
to length ofsequence
, andlength
to the length of the delimited subsequence. (So unlesslength
is specified there is only a single combination, which has the same elements as the delimited subsequence.) Ifcopy
is true (the default) each combination is freshly allocated. Ifcopy
is false all combinations areeq
to each other, in which case consequences are specified if a combination is modified byfunction
.- Provides
map-combinations
- Requires
- ensure-function
- map-permutations v1.0
-
Calls function with each permutation of
length
constructable from the subsequence ofsequence
delimited bystart
andend
.start
defaults to0
,end
to length of the sequence, andlength
to the length of the delimited subsequence.- Provides
map-permutations
- Requires
- map-combinations
- map-derangements v1.0
-
Calls
function
with each derangement of the subsequence ofsequence
denoted by the bounding index designatorsstart
andend
. Derangement is a permutation of the sequence where no element remains in place.sequence
is not modified, but individual derangements areeq
to each other. Consequences are unspecified if callingfunction
modifies either the derangement orsequence
.- Provides
map-derangements
- extremum v1.0
-
Returns the element of
sequence
that would appear first if the subsequence bounded bystart
andend
was sorted usingpredicate
andkey
.extremum
determines the relationship between two elements ofsequence
by using thepredicate
function.predicate
should return true if and only if the first argument is strictly less than the second one (in some appropriate sense). Two argumentsx
andy
are considered to be equal if(funcall predicate x y)
and(funcall predicate y x)
are both false.The arguments to the
predicate
function are computed from elements ofsequence
using thekey
function, if supplied. Ifkey
is not supplied or isnil
, the sequence element itself is used.If
sequence
is empty,nil
is returned.- Provides
extremum
- Requires
- ensure-function
- clamp v1.0
-
Clamps the
number
into [min
,max
] range. Returnsmin
ifnumber
is lesser thenmin
andmax
ifnumber
is greater thenmax
, otherwise returnsnumber
.- Provides
clamp
- gaussian-random v1.0
-
Returns two gaussian random double floats as the primary and secondary value, optionally constrained by
min
andmax
. Gaussian random numbers form a standard normal distribution around0.0d0
.Sufficiently positive
min
or negativemax
will cause the algorithm used to take a very long time. Ifmin
is positive it should be close to zero, and similarly ifmax
is negative it should be close to zero.- Provides
gaussian-random
- iota v1.0
-
Return a list of
n
numbers, starting fromstart
(with numeric contagion fromstep
applied), each consequtive number being the sum of the previous one andstep
.start
defaults to0
andstep
to1
.Examples:
(iota 4) => (0 1 2 3) (iota 3 :start 1 :step 1.0) => (1.0 2.0 3.0) (iota 3 :start -1 :step -1/2) => (-1 -3/2 -2)
- Provides
iota
- map-iota v1.0
-
Calls
function
withn
numbers, starting fromstart
(with numeric contagion fromstep
applied), each consequtive number being the sum of the previous one andstep
.start
defaults to0
andstep
to1
. Returnsn
.Examples:
(map-iota #'print 3 :start 1 :step 1.0) => 3 ;;; 1.0 ;;; 2.0 ;;; 3.0
- Provides
map-iota
- lerp v1.0
-
Returns the result of linear interpolation between
a
andb
, using the interpolation coefficientv
.- Provides
lerp
- mean v1.0
-
Returns the mean of
sample
.sample
must be a sequence of numbers.- Provides
mean
- median v1.0
-
Returns median of
sample
.sample
must be a sequence of real numbers.- Provides
median
- Requires
- copy-sequence
- variance v1.0
-
Variance of
sample
. Returns the biased variance ifbiased
is true (the default), and the unbiased estimator of variance ifbiased
is false.sample
must be a sequence of numbers.- Provides
variance
- Requires
- mean
- standard-deviation v1.0
-
Standard deviation of
sample
. Returns the biased standard deviation ifbiased
is true (the default), and the square root of the unbiased estimator for variance ifbiased
is false (which is not the same as the unbiased estimator for standard deviation).sample
must be a sequence of numbers.- Provides
standard-deviation
- Requires
- variance
- maxf v1.0
-
Modify-macro for
max
. Sets place designated by the first argument to the maximum of its original value andnumbers
.- Provides
maxf
- minf v1.0
-
Modify-macro for
min
. Sets place designated by the first argument to the minimum of its original value andnumbers
.- Provides
minf
- subfactorial v1.0
-
Subfactorial of the non-negative integer
n
.- Provides
subfactorial
- count-permutations v1.0
-
Number of
k
element permutations for a sequence ofn
objects.k
defaults ton
- Provides
count-permutations
- Requires
- range-product