Next: , Previous: Reference manual, Up: Reference manual


6.1 Package FL.UTILITIES

This package contains generally useful utility functions. Several of those functions were taken from (Graham 1996), the SANS function was contributed to the comp.lang.lisp newsgroup by Erik Naggum.

— Function: ARRAY-FOR-EACH FUNC &REST ARRAYS

Calls func on all element tuples of the array arguments.

— Function: BLACKBOARD &REST ITEMS

Make the property list supplied in items into a blackboard. Copies items to make sure that no literal list is modified.

— Class: BLACKBOARD

A blackboard where data items can be put and extracted using the function GETBB.

Direct slots:

— Function: BOX OBJECT

Boxes an object.

— Function: CHECK-PROPERTIES PLACE PROPERTIES

Checks if all of the properties are in the property list place.

— Function: COMMON-LISP-SPEED &KEY (CACHE 0.5) (MEMORY 0.5)

Returns the speed which should be characteristic for the setting determined by the keyword arguments.

— Function: CONCEPT-DOCUMENTATION DOCSTRING

Documents a certain concept.

— Function: COPY-HASH-TABLE HASH-TABLE

Copy hash-table.

— Function: CURRY FUNC &REST ARGS

Supplies args to func from the left.

— Function: DEQUEUE PQ

Pops an object from queue.

— Function: DIC-REF DIC KEY

Returns the value of the entry for key in dictionary.

— Function: DISPLAY-HT HASH-TABLE

Display hash-table in the form key1 -> value1 ...

— Macro: DOHASH (LOOPING-VAR HASH-TABLE) &BODY BODY

Loops through hash-table. If looping-var is an atom key, loop through the keys; if it is a list of the form (value) loop through the values; if it is a list of the form (key value) loop through key and value.

— Macro: DOTUPLE (INDEX LIMITS &OPTIONAL RESULT) &BODY BODY

Loops through each tuple below limits.

— Function: ENQUEUE OBJ PQ

Puts object into the queue.

— Function: FACTORIAL N

Compute the factorial of n. n can also be a list of numbers in which case the product of the factorials of the components is computed.

— Function: FILE-DOCUMENTATION DOCSTRING

If the manual is sorted by file, the string handed to this function describes the use of the respective file.

— Function: FIXNUM-VEC &REST ELEMENTS

Returns a FIXNUM-VEC constructed from the parameters.

— Type: FIXNUM-VEC

Vector with elements of type fixnum.

— Function: FLATTEN TREE

Flatten a tree. Example:

            (flatten '((1 2) (3) ((4))))  =>  (1 2 3 4)
     

— Function: FOR-EACH FUNC SEQ

Applies func to each element of collection.

— Function: FOR-EACH-TUPLE FUNC LIMITS

Calls func on each tuple greater or equal to (0 ... 0) and below dims.

— Function: GET-ARBITRARY-KEY-FROM-HASH-TABLE HASH-TABLE

Get an arbitrary key from hash-table.

— Function: GET-PROPERTY OBJECT PROPERTY

Gets property for object.

— Function: GETA ALIST KEY

An analog to GETF for association lists.

— Setf Expander: GETA

An analog to (SETF GETF) for association lists.

— Function: GETBB BLACKBOARD KEY &OPTIONAL DEFAULT

Get the item for key from blackboard. If there is no such key return default.

— Function: HASH-TABLE-KEYS HASH-TABLE

Collect the keys of hash-table into a list.

— Function: HASH-TABLE-VALUES HASH-TABLE

Collect the values of hash-table into a list.

— Function: IDENTITY-PERMUTATION-P PERM

Checks if the permutation is the identity.

— Function: ITERATOR X

Returns an iterator for x.

— Function: ITERATOR-NEXT RANGE I

Returns an incremented iterator.

— Function: K->L-SUBSETS SET K L

Returns all subsets of set with length between k and l. Example:

            (k->l-subsets '(1 2 3) 1 2) =>
            ((1) (2) (3) (1 2) (1 3) (2 3))
     

— Function: K-SUBSETS SET K

Returns all subsets of set with length k. Example:

            (k-subsets '(1 2 3) 2)
            => ((1 2) (1 3) (2 3))
     

— Function: LIST->QUEUE LIST

Transforms list to a queue.

— Macro: LOOP+ ITEMS &BODY BODY

Iterates body over items. Example:

            (let ((x (make-array 10))
          	(y (make-list 10 :initial-element 1)))
              (loop+ ((xc x) (yc y) i) doing
                 (setf xc (+ i yc))
                 finally (return x)))
     

— Function: MAKE-ANALOG PICTURE

Generate an analogous but empty data structure.

— Function: MAKE-FIXNUM-VEC DIM &OPTIONAL (INIT 0)

Construct a FIXNUM-VEC of size dim initialized by init.

— Function: MAP-HASH-TABLE FUNC HASH-TABLE

Call func given in the first argument on each key of hash-table. func must return the new key and the new value as two values. Those pairs are stored in a new hash-table.

— Function: MAP-PRODUCT FUNC LIST &REST REST-LISTS

Applies func to a product of lists. Example:

            (map-product #'cons '(2 3) '(1 4))
            => ((2 . 1) (2 . 4) (3 . 1) (3 . 4))
     

— Function: MAP-TREE FUNC TREE

Maps tree using func. Example:

            (map-tree #'1+ '((1 (2)))) => ((2 (3)))
     

— Function: MAPPEND FUNC &REST LISTS

Map func over lists while appending the results.

— Function: MAXIMALLY-CONNECTED CONNECTED DISCONNECTED &KEY (TEST (FUNCTION EQL)) (COMBINE (FUNCTION ADJOIN))

Finds a maximally connected set by taking the union of the elements in connected with the sets of disconnected-sets. Returns the maximally connected sets and the remaining disconnected ones. Example:

            (maximally-connected '(1 2) '((3 4) (2 3) (5 6))
                                 :test #'intersection :combine #'union)
            => (1 2 3 4), ((5 6))
     

— Function: MEMOIZE-1 FUNC &KEY (TEST (QUOTE EQL))

Memoizes the function func which should be a non-recursive function of one argument.

— Function: MEMOIZE-SYMBOL FUNSYM &KEY (TEST (QUOTE EQUAL))

Memoizes multi-argument functions named by the symbol funsym.

— Macro: MEMOIZING-LET BINDINGS &BODY BODY

The body is memoized for the keys given as a list of bindings.

— Function: MKLIST OBJ

Wraps obj in a list, if it is not already a list.

— Function: N-PARTITIONS-OF-K N K

Returns a list of all ordered partitions of k into n natural numbers. Example:

            (n-partitions-of-k 2 3)
             => ((0 3) (1 2) (2 1) (3 0))
     

— Function: NONEMPTY-SUBSETS SET

Returns a list of all nonempty subsets of set.

— Function: ON-LEAVES FUNC TREE

Executes func on the leaves of tree.

— Function: PARTIAL-SUMS SEQ

Returns a sequence of the same type as seq consisting of its partial sums.

— Function: PERMUTATION-INVERSE PERM-VEC

Returns the inverse of the permutation given by perm-vec.

— Function: PERMUTATION-P PERM

Checks if perm is a possible permutation vector. A permutation pi is characterized by a vector containing the indices from 0,..., length(perm)-1 in some order.

— Function: PERMUTATION-SIGNUM PERM

Returns the sign of perm.

— Function: PERMUTE PERM INDEX

Functional version of permute-into.

— Function: PERMUTE-INTO PERM V RESULT

A permutation perm acts on the vector v by permuting it according to result[i] = v[perm[i]].

— Type: POSITIVE-FIXNUM

Positive fixnum tpye.

— Function: POSITIVE-N-PARTITIONS-OF-K N K

Returns a list of all positive ordered partitions of k into n natural numbers. Example:

            (positive-n-partitions-of-k 2 3)
            => ((1 2) (2 1))
     

— Function: POSITIVE-PARTITIONS-OF-K K

Returns a list of all positive ordered partitions of k. Example:

            (positive-partitions-of-k 3) => ((1 2) (2 1))
     

— Class: PROPERTY-MIXIN

A mixin which adds a slot of properties to the class.

Direct slots:

— Function: PROPERTY-SET-P OBJECT PROPERTY

Returns T if property is found in the object's properties.

— Class: QUEUE

Queue class accessed with enqueue and dequeue.

Direct slots:

— Function: QUEUE->LIST QUEUE

Transforms queue to a list.

— Function: RANGE &REST ARGS &KEY TO BELOW

Constructor for a range of numbers.

— Class: RANGE

Range of numbers for iteration.

Direct slots:

— Function: RCURRY FUNC &REST ARGS

Supplies args to func from the right.

— Function: REFERENCE RANGE I

Reader for the element of vec referenced by iterator.

— Function: REQUIRED-ARGUMENT

Calling this function results in an error. Such a call may be used as default form when an argument should be supplied.

— Function: RUNTIME-COMPILE SOURCE

Calls compile on the provided source. When :compile is activated for debugging, the source code is printed.

— Function: SAME-P SEQUENCE &KEY (TEST (FUNCTION EQL)) (KEY (FUNCTION IDENTITY))

Returns t if sequence consists of equal elements.

— Function: SANS PLIST &REST KEYS

Removes the items marked by keys from the property list plist. This function was posted at 2.12.2002 to the comp.lang.lisp newsgroup by Erik Naggum.

— Function: SET-P LIST

Checks if list is a set, i.e. if no members occur twice.

— Function: SPLICE ITEMS LENGTHS

Breaks the list items in pieces of lengths determined by nrins. Example:

            (splice '(1 2 3 4) '(1 3)) => ((1) (2 3 4))
     

— Function: SQUARE X

Return the square of x.

— Function: SUBSETS SET

Returns a list of all subsets of set.

— Function: TRANSFER-BB FROM-BB TO-BB ITEMS &KEY ENSURE

Transfer items between the blackboards from-bb and to-bb. When ensure is set, an existing item is not modified.

— Function: UNBOX BOX

Getter for a boxed object.

— Function: VECTOR-LAST VEC

Returns the last element of vec.

— Function: VECTOR-MAP FUNC &REST VECS

Map vec with func to a vector of the same type.

— Macro: WITH-ITEMS PROPERTIES BLACKBOARD-FORM &BODY BODY

Work with the items on blackboard corresponding to properties. If some property is a list, the second element is the default value and the third is an alias to be used to refer to this parameter. Example:

            (with-items (&key sol (rhs nil rhs-high)) blackboard
               (setq sol rhs-high))
     

— Macro: WITH-MEMOIZATION (&KEY (TYPE GLOBAL) SIZE ID (DEBUG T) (TEST (QUOTE (QUOTE EQUAL)))) &BODY BODY

Sets up a memoization environment consisting of a table, and a captured symbol memoizing-let memoizing its body depending on the arguments. Example of usage:

            (with-memoization (:type :local :id 'test)
              (defun test (n)
                (memoizing-let ((k (* 2 n)))
          	(sleep 1)
          	(* k k))))
     

If type is :global, the table is thread-safe and the same for all threads, if type is :local, it is special for each thread.

— Macro: WITH-PROPERTIES PROPERTIES OBJECT &BODY BODY

Work with properties on the property list of object.

— Function: ZERO-VECTOR DIM ELEMENT-TYPE

Returns a uniform vector for the given element type filled with zeros.