This package exports list processing functions. License: AGPL3 Copyright Pascal J. Bourguignon 2003 - 2014 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>
(aget place indicator &optional default) |
function |
RETURN: The value of the entry INDICATOR of the a-list PLACE, or DEFAULT.
(appendf x &rest lists) |
macro |
Append the LISTS at the end of the PLACE.
(circular-length list) |
function |
LIST must be either a proper-list or a circular-list, not a dotted-list. RETURN: the total length ; the length of the stem ; the length of the circle.
(combine &rest args) |
function |
RETURN: (elt args 0) x (elt args 1) x ... x (elt args (1- (length args))) = the set of tuples built taking one item in order from each list in args. EXAMPLE: (COMBINE '(WWW FTP) '(EXA) '(COM ORG))) --> ((WWW EXA COM) (WWW EXA ORG) (FTP EXA COM) (FTP EXA ORG))
(deepest tree) |
function |
RETURN: The deepest list in the tree. NOTE: Iterative algorithm. SEE-ALSO: deepest-rec
(deepest-rec tree) |
function |
RETURN: The deepest list in the tree. NOTE: Recursive algorithm. SEE-ALSO: deepest-iti
(depth tree) |
function |
RETURN: The depth of the tree.
(ensure-circular list) |
function |
If list is not a circular list, then modify it to make it circular. RETURN: LIST
(ensure-list object) |
function |
RETURN: If OBJECT is a list then OBJECT, otherwise a fresh list containing OBJECT.
(equivalence-classes set &key test key) |
function |
RETURN: The equivalence classes of SET, via KEY, modulo TEST.
(flatten tree) |
function |
RETURN: A list containing all the elements of the `tree'.
(hashed-intersection set1 set2) |
function |
AUTHORS: Paul F. Dietz <dietz@dls.net> Thomas A. Russ <tar@sevak.isi.edu>
(iota count &optional start step) |
function |
RETURN: A list containing the elements (start start+step ... start+(count-1)*step) The start and step parameters default to 0 and 1, respectively. This procedure takes its name from the APL primitive. EXAMPLE: (iota 5) => (0 1 2 3 4) (iota 5 0 -0.1) => (0 -0.1 -0.2 -0.3 -0.4)
(list-elements clist) |
function |
CLIST is any kind of list: proper-list, circular-list or dotted-list. RETURN: for a proper list: a copy of clist, the length of the list and 0; for a circular list: a list of elements in the clist, the length of the stem, and the length of the circle; for a dotted list: a list of the elements in the clist, the number of cons cells, and nil; for an atom: a list of the atom, 0, and nil.
(list-insert-separator list separator) |
function |
RETURN: A list composed of all the elements in `list' with `separator' in-between. EXAMPLE: (list-insert-separator '(a b (d e f) c) 'x) ==> (a x b x (d e f) x c)
(list-lengths list) |
function |
LIST is any kind of list: proper-list, circular-list or dotted-list. RETURN: for a proper list, the length of the list and 0; for a circular list, the length of the stem, and the length of the circle; for a dotted list, the number of cons cells, and nil; for an atom, 0, and nil.
(list-trim bag list &key test key) |
function |
RETURN: A sublist of LIST with the elements in the BAG removed from both ends.
(make-circular-list size &key initial-element) |
function |
RETURN: a new circular list of length SIZE. POST: (circular-length (make-circular-list size)) == (values size 0 size)
(make-list-of-random-numbers length &key modulo) |
function |
RETURN: A list of length `length' filled with random numbers MODULO: The argument to RANDOM.
(map-cartesian-product fun &rest lists) |
function |
DO: Call FUN with as arguments the elements of the cartesian products of the lists in LISTS. RETURN: A list of all the results of FUN. EXAMPLE: (map-cartesian-product (function list) '(1 2 3) '(a b c) '(11 22)) --> ((1 a 11) (1 a 22) (1 b 11) (1 b 22) (1 c 11) (1 c 22) (2 a 11) (2 a 22) (2 b 11) (2 b 22) (2 c 11) (2 c 22) (3 a 11) (3 a 22) (3 b 11) (3 b 22) (3 c 11) (3 c 22))
(maptree fun &rest trees) |
function |
DO: Calls FUN on each non-null atom of the TREES. PRE: The trees in TREES must be congruent, or else the result is pruned like the smallest tree. RETURN: A tree congruent to the TREES, each node being the result of FUN (it may be a subtree).
(memq item list) |
function |
RETURN: (MEMBER ITEM LIST :TEST (FUNCTION EQ))
(meta-list list) |
function |
Returns a list whose CARs are the CONS cells of the LIST. LIST must be a proper list.
(nsplit-list list position &key from-end) |
function |
PRE: 0<=POSITION<=(LENGTH LIST) DO: SPLIT THE LIST IN TWO AT THE GIVEN POSITION. (NSPLIT-LIST (LIST 'A 'B 'C) 0) --> NIL ; (A B C) (NSPLIT-LIST (LIST 'A 'B 'C) 1) --> (A) ; (B C) (NSPLIT-LIST (LIST 'A 'B 'C) 2) --> (A B) ; (C) (NSPLIT-LIST (LIST 'A 'B 'C) 3) --> (A B C) ; NIL POSITION: POSITION OF THE SPLIT; WHEN FROM-START AND 0<=POSITION<=(LENGTH LIST), THAT'S THE LENGTH OF THE FIRST RESULT FROM-START: THE DEFAULT, SPLIT COUNTING FROM THE START. FROM-END: WHEN SET, COUNT FROM THE END OF THE LIST. (NSPLIT-LIST L P :FROM-END T) === (NSPLIT-LIST L (- (LENGTH L) P)) RETURN: THE FIRST PART ; THE LAST PART
(nsplit-list-on-indicator list indicator) |
function |
RETURN: a list of sublists of list (the conses from list are reused), the list is splited between items a and b for which (indicator a b).
(plist-cleanup plist) |
function |
Returns a plist that has the same associations than PLIST, but with a single occurence of each key and the first value found. EXAMPLE: (plist-cleanup '(:a 1 :b 2 :a 11 :c 3)) --> (:b 2 :c 3 :a 1)
(plist-get plist prop) |
function |
Extract a value from a property list. PLIST is a property list, which is a list of the form (PROP1 VALUE1 PROP2 VALUE2...). This function returns the value corresponding to the given PROP, or nil if PROP is not one of the properties on the list.
(plist-keys plist) |
function |
Returns a list of the properties in PLIST.
(plist-put plist prop value) |
function |
Change value in PLIST of PROP to VALUE. PLIST is a property list, which is a list of the form (PROP1 VALUE1 PROP2 VALUE2 ...). PROP is a symbol and VALUE is any object. If PROP is already a property on the list, its value is set to VALUE, otherwise the new PROP VALUE pair is added. The new plist is returned; use `(setq x (plist-put x prop val))' to be sure to use the new value. The PLIST is modified by side effects.
(plist-remove plist prop) |
function |
DO: (REMF PLIST PROP) RETURN: The modified PLIST.
PREPEND
(prependf x &rest lists) |
macro |
Prepend the LISTS at the beginning of the PLACE.
(proper-list-p object) |
function |
RETURN: whether OBJECT is a proper list NOTE: terminates with any kind of list, dotted, circular, etc.
PUSH*
(replace-tree dst src) |
function |
DO: Copies the elements of the src tree into the dst tree. If dst is missing cons cells, structure sharing occurs. RETURN: dst
(subsets set) |
function |
RETURN: The set of all subsets of the strict SET.
(transpose tree) |
function |
RETURN: A tree where all the CAR and CDR are exchanged.
(tree-difference a b &key test) |
function |
RETURN: A tree congruent to A and B where each node is = when the corresponding nodes are equal (as indicated by TEST), or (/= a-elem b-elem) otherwise. EXAMPLE: (tree-difference '((a b c) 1 (d e f)) '((a b c) (1) (d x f))) --> ((= = = . =) (/= 1 (1)) (= (/= e x) = . =) . =)
(tree-find object tree &key key test) |
function |
RETURN: The object in TREE that matches OBJECT (using the KEY and TEST functions. TREE: A sexp.