Package alexandria

alexandria is a collection of portable public domain utilities.

About This Package

Overview
Introduction
Hash Tables
Data and Control Flow
Conses
Sequences
Macro Writing
Symbols
Arrays
Types
Conditions
Numbers

Overview

Authors
Nikodemus Siivola
Attila Lendvai
Marco Baringer
Robert Strandh
Luis Oliveira
Tobias C. Rittweiler

Version
This is the documentation of the library taken from the Git repository (see below). The last modification of the documented source code was done on 2012-04-26.

Homepage
http://common-lisp.net/project/alexandria/

Mailing lists
http://lists.common-lisp.net/mailman/listinfo/alexandria-devel
http://lists.common-lisp.net/mailman/listinfo/alexandria-cvs

Download and Source Code
http://common-lisp.net/gitweb?p=projects/alexandria/alexandria.git

Documentation
The draft version of the documentation is available at
http://common-lisp.net/project/alexandria/draft/alexandria.html.

This documentation is based on the above version. The documentation has been generated with the library atdoc.

License
alexandria software and associated documentation are in the public domain:

Authors dedicate this work to public domain, for the benefit of the public at large and to the detriment of the authors' heirs and successors. Authors intends this dedication to be an overt act of relinquishment in perpetuity of all present and future rights under copyright law, whether vested or contingent, in the work. Authors understands that such relinquishment of all rights includes the relinquishment of all rights to enforce (by lawsuit or otherwise) those copyrights in the work.

Authors recognize that, once placed in the public domain, the work may be freely reproduced, distributed, transmitted, used, modified, built upon, or otherwise exploited by anyone for any purpose, commercial or non-commercial, and in any way, including by methods that have not yet been invented or conceived.

In those legislations where public domain dedications are not recognized or possible, alexandria is distributed under the following terms and conditions:

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Introduction

alexandria is a project and a library.

As a project alexandria's goal is to reduce duplication of effort and to improve portability of Common Lisp code according to its own idiosyncratic and rather conservative aesthetic. What this actually means is open to debate, but each project member has a veto on all project activities, so a degree of conservativism is inevitable.

As a library alexandria is one of the means by which the project strives for its goals.

alexandria is a collection of portable public domain utilities that meet the following constraints:
  • Utilities, not extensions: alexandria will not contain conceptual extensions to Common Lisp, instead limiting itself to tools and utilities that fit well within the framework of standard ANSI Common Lisp. Test-frameworks, system definitions, logging facilities, serialization layers, etc. are all outside the scope of alexandria as a library, though well within the scope of alexandria as a project.
  • Conservative: alexandria limits itself to what project members consider conservative utilities. alexandria does not and will not include anaphoric constructs, loop-like binding macros, etc.
  • Portable: alexandria limits itself to portable parts of Common Lisp. Even apparently conservative and useful functions remain outside the scope of alexandria if they cannot be implemented portably. Portability is here defined as portable within a conforming implementation. Implementation bugs are not considered portability issues.
  • Team player: alexandria will not (initially, at least) subsume or provide functionality for which good-quality special-purpose packages exist, like the library split-sequence. Instead, third party packages such as that may be "blessed".

Hash Tables

Acessor which ensures a value for a key in the hash table. ...

Returns a copy of hash table table, with the same keys and values as table. ...

Iterates over all keys in a hash table. ...

Iterates over all values in a hash table. ...

Returns a list containing the keys of the hash table table. ...

Returns a list containing the values of the hash table table. ...

Generates an association list from a hash table. ...

Generates a property list from a hash table. ...

Generates a hash table from an association list. ...

Generates a hash table from a property list. ...

Data and Control Flow

Ensures that the global variable named by name is a constant with a value that is equal under test to the result of evaluating initial-value. ...

The macro destructuring-case is a combination of the Common Lisp macros case and destructuring-bind. ...

The macro destructuring-ccase is a combination of the Common Lisp macros ccase and destructuring-bind. ...

The macro destructuring-ecase is a combination of ecase and destructuring-bind. ...

Multiple-place modify macro for ensure-function. ...

Like the Common Lisp special operator multiple-value-prog1 but evaluates first-form, then second-form, and then forms. Yields as its value all the values returned by second-form. ...

Expands into a lambda expression within whose body the argument name denotes the corresponding function.

Evaluates form arguments one at a time, until the nth-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 returns a true nth value, the return value is nil.

Creates new variable bindings, and conditionally executes either then-form or else-form. else-form defaults to nil. ...

Creates new variable bindings, and conditionally executes forms. ...

Creates new variable bindings, and conditionally executes forms. ...

Evaluates the first matching clause, returning its values, or evaluates and returns the values of default if no keys match.

Like switch, but signals a continuable error if no key matches.

Like switch, but signals an error if no key matches.

Evaluates exactly one of possibilities, chosen at random.

The logical operation exclusive or. ...

Returns a function that applies each of predicate and more-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.

Returns a function that applies each of predicate and more-predicate functions in turn to its arguments, returning nil 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.

Returns a function composed of function and more-functions that applies its arguments to to each in turn, starting from the rightmost of more-functions, and then calling the next one with the primary value of the last.

Returns the function designated by function-designator. ...

Returns a function composed of function and more-functions that applies its arguments to each in turn, starting from the rightmost of more-functions, and then calling the next one with all the return values of the last.

Returns a function that applies arguments and the arguments it is called with to function. ...

Returns a function that applies the arguments it is called with and arguments to function. ...

Conses

Type designator for proper lists. Implemented as a satisfies type, hence not recommended for performance intensive use. Main usefullness as a type designator of the expected type in a type-error .

Type designator for circular lists. Implemented as a satisfies type, so not recommended for performance intensive use. Main usefullness as a type designator of the expected type in a type-error .

Modify-macro for append. Appends lists to the place designated by the first argument place. ...

Modify-macro for nconc. Concatenates lists to place designated by the first argument. ...

Modify macro for remove-from-plist.

Modify macro for delete-from-plist.

Modify-macro for reverse. Copies and reverses the list stored in the given place and saves back the result into place.

Modify-macro for nreverse. Reverses the list stored in the given place by destructively modifying it and saves back the result into place.

Modify-macro for union. Saves the union of list and the contents of place designated by the first argument to the designated place.

Modify-macro for nunion. Saves the union of list and the contents of the place designated by the first argument to the designated place. May modify either argument.

Iterates over elements of a property list. body can be preceded by declarations, and is like a tagbody. return may be used to terminate the iteration early. If return is not used, returns values.

Returns true if object is a circular list, nil otherwise.

Returns true if object is a circular tree, nil otherwise.

Returns true if object is a proper list.

Returns a property list containing the same keys and values as the association list alist in the same order.

Returns an association list containing the same keys and values as the property list plist in the same order.

Creates a circular list of elements.

Creates a circular list of length with the given initial-element.

If thing is a cons, its car is returned. Otherwise thing is returned.

If cons is a cons, it is returned. Otherwise returns a fresh cons with cons in the car, and nil in the cdr.

If list is a list, it is returned. Otherwise returns the list designated by list.

Traverses the tree in order, collecting non-null leaves into a list.

Returns the last element of list. Signals a type-error if list is not a proper list.

Returns length of list, signalling an error if it is not a proper list.

Applies function to respective elements of each list, appending all the result lists to a single list. function must return a list.

Returns a list containing the results of calling function with one argument from list, and one from each of more-lists for each combination of arguments. In other words, returns the product of list and more-lists using function. ...

Returns a propery list with same keys and values as plist, except that keys in the list designated by keys and values corresponding to them are removed. The returned property list may share structure with plist, but plist is not destructively modified. Keys are compared using eq.

Just like remove-from-plist, but this version may destructively modify the provided plist.

Returns true if every element of list1 matches some element of list2 and every element of list2 matches some element of list1. Otherwise returns false.

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 under key and test.

Sequences

Type designator for proper sequences, that is proper lists and sequences that are not lists.

Modify-macro for delete. Sets place designated by the first argument to the result of calling delete with the arguments item, place, and remove-keywords.

Modify-macro for remove. Sets place designated by the first argument to the result of calling remove with the arguments item, place, and remove-keywords.

Returns a sequence of the same type as sequence, with the elements of sequence rotated by n. n elements are moved from the end of sequence to the front if n is positive, and -n elements moved from the front to the end if n is negative. ...

Returns a random permutation of sequence bounded by start and end. The permuted sequence may share storage with the original one. Signals an error if sequence is not a proper sequence.

Returns a random element from sequence bounded by start and end. Signals an error if sequence is not a proper sequence.

Returns true if sequence is an empty sequence. Signals an error if sequence is not a sequence.

Returns true if sequence is a sequence of length length. Signals an error if sequence is not a sequence. Returns false for circular lists.

Takes any number of sequences or integers in any order. Returns true iff the length of all the sequences and the integers are equal. ...

Returns a fresh sequence of type, which has the same elements as sequence. ...

Returns the first element of sequence. Signals an error of type type-error if sequence is not a sequence, or is an empty sequence. ...

Returns the last element of sequence. Signals an error of type type-error if sequence is not a proper sequence, or is an empty sequence. ...

Returns true if sequence is a sequence whose first element is eql to object. Returns nil if sequence is not a sequence or is an empty sequence.

Test whether the first elements of sequence are the same (as per test) as the elements of prefix. ...

Returns true if sequence is a sequence whose last element is eql to object. Returns nil if sequence is not a sequence or is an empty sequence. Signals an error if sequence is an improper list.

Test whether sequence ends with suffix. In other words: return true if the last (length suffix) elements of sequence are equal to suffix.

Calls function with each combination of length constructable from the elements of the subsequence of sequence delimited by start and end. ...

Calls function with each derangement of the subsequence of sequence denoted by the bounding index designators start and end. ...

Calls function with each permutation of length constructable from the subsequence of sequence delimited by start and end. ...

Macro Writing

Evaluates forms with symbols specified in specs rebound to temporary variables, ensuring that each initform is evaluated only once. ...

Binds each variable named by a symbol in names to a unique symbol around forms. ...

Alias for with-gensyms.

Returns t if the argument feature-expression matches the state of the *features* list and nil if it does not. ...

Parses body into (values remaining-forms declarations doc-string). Documentation strings are recognized only if documentation is true. Syntax errors in body are signalled and whole is used in the signal arguments when given.

Parses an ordinary lambda-list, returning as multiple values ...

Symbols

Returns a symbol with name designated by name, accessible in package designated by package. ...

Constructs a string by applying arguments to string designator control as if by format, and then creates a symbol named by that string. If package is nil, returns an uninterned symbol, if package is t, returns a symbol interned in the current package, and otherwise returns a symbol interned in the package designated by package.

Interns the string designated by name in the keyword package.

If name is a non-negative integer, calls gensym using it. Otherwise name must be a string designator, in which case calls gensym using the designated string as the argument.

Returns a list of length gensyms, each generated as if with a call to make-gensym, using the second (optional, defaulting to "G") argument.

Concatenate together the names of some strings and symbols, producing a symbol in the current package.

Arrays

Type designator for an index into array of length: an integer between 0 (inclusive) and length (exclusive). length defaults to array-dimension-limit.

Type designator for a dimension of an array of length: an integer between 0 (inclusive) and length (inclusive). length defaults to array-dimension-limit.

Types

A string designator type. A string designator is either a string, a symbol, or a character.

Modify-macro for the Common Lisp function coerce.

Returns a function of one argument, which returns true when its argument is of type.

Returns a primary value of t if type1 and type2 are the same type, and a secondary value that is true if the type equality could be reliably determined: primary value of nil and secondary value of t indicates that the types are not equivalent.

Conditions

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. ...

Similar to ignore-errors but the (unevaluated) conditions list determines which specific conditions are to be ignored. ...




Like unwind-protect, but you can specify the circumstances that the cleanup clauses are run. ...

Numbers

Modify-macro for max. Sets place designated by the first argument to the maximum of its original value and numbers. ...

Modify-macro for min. Sets place designated by the first argument to the minimum of its original value and numbers. ...

Binomial coefficient of n and k, also expressed as n choose k. ...

Number of k element permutations for a sequence of n objects. k defaults to n. ...

Clamps the number into [min, max] range. Returns min if number is lesser then min and max if number is greater then max, otherwise returns number ...

Returns the result of linear interpolation between a and b, using the interpolation coefficient v. ...

Factorial of the non-negative integer n ...

Subfactorial of the non-negative integer n.

Returns two gaussian random double floats as the primary and secondary value, optionally constrained by min and max. Gaussian random numbers form a standard normal distribution around 0.0d0 ...

Return a list of n numbers, starting from start (with numeric contagion from step applied), each consequtive number being the sum of the previous one and step. start defaults to 0 and step to 1. ...

Calls function with n numbers, starting from start (with numeric contagion from step applied), each consequtive number being the sum of the previous one and step. start defaults to 0 and step to 1. Returns n. ...

Returns the mean of sample. sample must be a sequence of numbers. ...

Returns the median of sample. sample must be a sequence of real numbers. ...

Variance of sample. Returns the biased variance if biased is true (the default), and the unbiased estimator of variance if biased is false. sample must be a sequence of numbers. ...

Standard deviation of a sample. ...

Exported Symbol Index

alist-hash-table, Function
alist-plist, Function
appendf, Macro
array-index, Type
array-length, Type
assoc-value, Function
binomial-coefficient, Function
circular-list, Function
circular-list, Type
circular-list-p, Function
circular-tree-p, Function
clamp, Function
coercef, Macro
compose, Function
conjoin, Function
copy-array, Function
copy-file, Function  (undocumented)
copy-hash-table, Function
copy-sequence, Function
copy-stream, Function
count-permutations, Function
cswitch, Macro
curry, Function
define-constant, Macro
delete-from-plist, Function
delete-from-plistf, Macro
deletef, Macro
destructuring-case, Macro
destructuring-ccase, Macro
destructuring-ecase, Macro
disjoin, Function
doplist, Macro
emptyp, Function
ends-with, Function
ends-with-subseq, Function
ensure-car, Function
ensure-cons, Function
ensure-function, Function
ensure-functionf, Macro
ensure-gethash, Macro
ensure-list, Function
ensure-symbol, Function
eswitch, Macro
extremum, Function
factorial, Function
featurep, Function
first-elt, Function
flatten, Function
format-symbol, Function
gaussian-random, Function
hash-table-alist, Function
hash-table-keys, Function
hash-table-plist, Function
hash-table-values, Function
if-let, Macro
ignore-some-conditions, Macro
iota, Function
last-elt, Function
lastcar, Function
length=, Function
lerp, Function
make-circular-list, Function
make-gensym, Function
make-gensym-list, Function
make-keyword, Function
map-combinations, Function
map-derangements, Function
map-iota, Function
map-permutations, Function
map-product, Function
maphash-keys, Function
maphash-values, Function
mappend, Function
maxf, Macro
mean, Function
median, Function
minf, Macro
multiple-value-compose, Function
multiple-value-prog2, Macro
named-lambda, Macro
nconcf, Macro
negative-double-float, Type
negative-double-float-p, Function
negative-fixnum, Type
negative-fixnum-p, Function
negative-float, Type
negative-float-p, Function
negative-integer, Type
negative-integer-p, Function
negative-long-float, Type
negative-long-float-p, Function
negative-rational, Type
negative-rational-p, Function
negative-real, Type
negative-real-p, Function
negative-short-float, Type
negative-short-float-p, Function
negative-single-float, Type
negative-single-float-p, Function
non-negative-double-float, Type
non-negative-double-float-p, Function
non-negative-fixnum, Type
non-negative-fixnum-p, Function
non-negative-float, Type
non-negative-float-p, Function
non-negative-integer, Type
non-negative-integer-p, Function
non-negative-long-float, Type
non-negative-long-float-p, Function
non-negative-rational, Type
non-negative-rational-p, Function
non-negative-real, Type
non-negative-real-p, Function
non-negative-short-float, Type
non-negative-short-float-p, Function
non-negative-single-float, Type
non-negative-single-float-p, Function
non-positive-double-float, Type
non-positive-double-float-p, Function
non-positive-fixnum, Type
non-positive-fixnum-p, Function
non-positive-float, Type
non-positive-float-p, Function
non-positive-integer, Type
non-positive-integer-p, Function
non-positive-long-float, Type
non-positive-long-float-p, Function
non-positive-rational, Type
non-positive-rational-p, Function
non-positive-real, Type
non-positive-real-p, Function
non-positive-short-float, Type
non-positive-short-float-p, Function
non-positive-single-float, Type
non-positive-single-float-p, Function
nreversef, Macro
nth-value-or, Macro
nunionf, Macro
of-type, Function
once-only, Macro
ordinary-lambda-list-keywords, Symbol
parse-body, Function
parse-ordinary-lambda-list, Function
plist-alist, Function
plist-hash-table, Function
positive-double-float, Type
positive-double-float-p, Function
positive-fixnum, Type
positive-fixnum-p, Function
positive-float, Type
positive-float-p, Function
positive-integer, Type
positive-integer-p, Function
positive-long-float, Type
positive-long-float-p, Function
positive-rational, Type
positive-rational-p, Function
positive-real, Type
positive-real-p, Function
positive-short-float, Type
positive-short-float-p, Function
positive-single-float, Type
positive-single-float-p, Function
proper-list, Type
proper-list-length, Function
proper-list-p, Function
proper-sequence, Type
random-elt, Function
rassoc-value, Function
rcurry, Function
read-file-into-byte-vector, Function
read-file-into-string, Function
remove-from-plist, Function
remove-from-plistf, Macro
removef, Macro
required-argument, Function
reversef, Macro
rotate, Function
sequence-of-length-p, Function
set-equal, Function
setp, Function
shuffle, Function
simple-parse-error, Function  (undocumented)
simple-parse-error, Condition  (undocumented)
simple-program-error, Function  (undocumented)
simple-program-error, Condition  (undocumented)
simple-reader-error, Function  (undocumented)
simple-reader-error, Condition  (undocumented)
simple-style-warning, Function  (undocumented)
simple-style-warning, Condition  (undocumented)
standard-deviation, Function
starts-with, Function
starts-with-subseq, Function
string-designator, Type
subfactorial, Function
switch, Macro
symbolicate, Function
type=, Function
unionf, Macro
unwind-protect-case, Macro
variance, Function
when-let, Macro
when-let*, Macro
whichever, Macro
with-gensyms, Macro
with-input-from-file, Macro
with-output-to-file, Macro
with-unique-names, Macro
write-byte-vector-into-file, Function
write-string-into-file, Function
xor, Macro