Next: Package FL.MACROS, Previous: Reference manual, Up: Reference manual
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.
Make the property list supplied in items into a blackboard. Copies items to make sure that no literal list is modified.
A blackboard where data items can be put and extracted using the function
GETBB.Direct slots:
- ITEMS: A property list of items on the blackboard.
Checks if all of the properties are in the property list place.
Returns the speed which should be characteristic for the setting determined by the keyword arguments.
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.
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.
If the manual is sorted by file, the string handed to this function describes the use of the respective file.
Calls func on each tuple greater or equal to (0 ... 0) and below dims.
Get the item for key from blackboard. If there is no such key return default.
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))
Returns all subsets of set with length k. Example:
(k-subsets '(1 2 3) 2) => ((1 2) (1 3) (2 3))
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)))
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.
Applies func to a product of lists. Example:
(map-product #'cons '(2 3) '(1 4)) => ((2 . 1) (2 . 4) (3 . 1) (3 . 4))
Maps tree using func. Example:
(map-tree #'1+ '((1 (2)))) => ((2 (3)))
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))
Memoizes the function func which should be a non-recursive function of one argument.
Memoizes multi-argument functions named by the symbol funsym.
The body is memoized for the keys given as a list of bindings.
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))
Returns a sequence of the same type as seq consisting of its partial sums.
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.
A permutation perm acts on the vector v by permuting it according to result[i] = v[perm[i]].
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))
Returns a list of all positive ordered partitions of k. Example:
(positive-partitions-of-k 3) => ((1 2) (2 1))
A mixin which adds a slot of properties to the class.
Direct slots:
- PROPERTIES: A property list which is used to store unstructured information about this object.
Range of numbers for iteration.
Direct slots:
- FROM: Start of range, defaults to 0.
- TO: Inclusive end of range, defaults to infinity.
- BELOW: Exclusive end of range, defaults to infinity.
- BY: Step size.
Calling this function results in an error. Such a call may be used as default form when an argument should be supplied.
Calls compile on the provided source. When :compile is activated for debugging, the source code is printed.
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.
Breaks the list items in pieces of lengths determined by nrins. Example:
(splice '(1 2 3 4) '(1 3)) => ((1) (2 3 4))
Transfer items between the blackboards from-bb and to-bb. When ensure is set, an existing item is not modified.
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))
Sets up a memoization environment consisting of a table, and a captured symbol
memoizing-letmemoizing 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.