Quickutilβ

Lisp utilities on demand

Fork me on GitHub
search

There are 54 utilities.

range v1.0

Return the list of numbers n such that start <= n < end and n = start + k*step for suitable integers k. If a function key is provided, then apply it to each number.

Provides
range
Source Code
 
replicate v1.0

Make a list of n copies of x.

Provides
replicate
Source Code
 
slice v1.0

Compute the slice of a list list at indexes indexes.

Provides
slice
Source Code
 
transpose v1.0

Analog to matrix transpose for a list of lists given by lists.

Provides
transpose
Source Code
 
zip v1.0

Take a tuple of lists and turn them into a list of tuples. Equivalent to unzip.

Provides
zip
Requires
transpose
Source Code
 
unzip v1.0

Take a list of tuples and return a tuple of lists. Equivalent to zip.

Provides
unzip
Requires
transpose
Source Code
 
long-zip v1.0

zip using the longest, rather than shortest list, filling with fill.

Provides
long-zip
Requires
zip
Source Code
 
enumerate v1.0

Equivalent to (zip (iota (length list)) list).

Provides
enumerate
Source Code
 
flatten-once v1.0

Flatten list once.

Provides
flatten-once
Source Code
 
flatten-tagged-once v1.0

Flatten once a list x with a tag tag.

Provides
flatten-tagged-once
Source Code
 
flatten v1.0

Flatten (and append) all lists xs completely.

Provides
flatten
Source Code
 
ncycle v1.0

Mutate list into a circlular list.

Provides
ncycle
Source Code
 
cycle v1.0

Make list into a circular list.

Provides
cycle
Requires
ncycle
Source Code
 
nest v1.0

Compute a count compositions of function on initial-value.

Provides
nest
Source Code
 
nest-list v1.0

Compute a list of count compositions of function on initial-value.

Provides
nest-list
Source Code
 
safe-nth v1.0

Find the nth element of list. If n is out of bounds, return if-out-of-bounds (nil by default).

Provides
safe-nth
Source Code
 
mapply v1.0

Apply f to each list of arguments contained within list and collect the results.

Provides
mapply
Source Code
 
cartesian-product v1.0

Compute the cartesian product of l1 and l2 as if they were sets. Optionally, map the function f across the product.

Provides
cartesian-product
Source Code
 
end v1.0

Return the last element of list and whether or not it was empty.

Provides
end
Source Code
 
tabulate v1.0

Return a list evaluations of f over the integers [0,n). Mimics the SML function of the same name.

Provides
tabulate
Requires
range
Source Code
 
collect-reduce v1.0

Collects intermediate reduction results of applying f to list. More or less equivalent to (loop :for i :in list :collect (reduce f i)).

Provides
collect-reduce
Source Code
 
weave v1.0

Return a list whose elements alternate between each of the lists lists. Weaving stops when any of the lists has been exhausted.

Provides
weave
Source Code
 
interleave v1.0

Return a list whose elements alternate between each of the lists lists. When a list has been exhausted, interleaving continues with whatever other non-empty lists.

Provides
interleave
Source Code
 
riffle v1.0

Insert the item obj in between each element of list.

Provides
riffle
Source Code
 
extend v1.0

Adjoin x to the end of xs.

Provides
extend
Source Code
 
list-to-vector v1.0

Convert list into a vector.

Provides
list-to-vector
Source Code
 
sequence-to-list v1.0

Convert the sequence seq into a list.

Provides
sequence-to-list
Source Code
 
explode v1.0

The classic explode function. Take a string and return a list of its characters.

Provides
explode
Requires
sequence-to-list
Source Code
 
implode v1.0

The classic implode function. Take a list of characters and return the corresponding string.

Provides
implode
Requires
list-to-vector
Source Code
 
inits v1.0

Generate a list of initial sublists of the list list. The name inits comes from the Haskell function of the same name.

Example:

> (inits '(a b c d))  
(NIL (A) (A B) (A B C) (A B C D)) 
Provides
inits
Source Code
 
tails v1.0

Generate a list of tails of the list list. The name tails comes from the Haskell function of the same name.

Example

> (tails '(a b c d))  
((A B C D) (B C D) (C D) (D) NIL) 
Provides
tails
Source Code
 
array-contents v1.0

Extract the contents of the array array, returning a value that would be suitable to pass to the :initial-contents keyword argument of make-array.

Provides
array-contents
Source Code
 
alist-plist v1.0

Convert between alists and plists.

Provides
alist-plistplist-alist
Requires
safe-endp
Source Code
 
assoc-value v1.0

Getters and setters for assoc and rassoc values.

Provides
assoc-valuerassoc-value
Requires
with-gensyms
Source Code
 
doplist v1.0

Iterates over elements of plist. 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.

Provides
doplist
Requires
parse-body, with-gensyms
Source Code
 
appendf v1.0

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

Provides
appendf
Source Code
 
nconcf v1.0

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

Provides
nconcf
Source Code
 
unionf v1.0

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

Provides
unionf
Source Code
 
nunionf v1.0

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.

Provides
nunionf
Source Code
 
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
Source Code
 
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
Source Code
 
circular-list v1.0

Creation and detection of circular lists.

Provides
circular-listcircular-list-pmake-circular-list
Source Code
 
proper-list-p v1.0

Returns true if object is a proper list.

Provides
proper-list-p
Source Code
 
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 a type-error.

Provides
proper-list
Requires
proper-list-p
Source Code
 
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-lengthlast-car
Requires
circular-list, safe-endp
Source Code
 
ensure-car v1.0

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

Provides
ensure-car
Source Code
 
ensure-cons v1.0

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

Provides
ensure-cons
Source Code
 
ensure-list v1.0

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

Provides
ensure-list
Source Code
 
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-plistdelete-from-plistremove-from-plistfdelete-from-plistfsans
Source Code
 
mappend v1.0

Applies function to respective element(s) of each list, appending all the all the result list to a single list. function must return a list.

Provides
mappend
Source Code
 
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 under key and test.

Provides
setp
Source Code
 
set-equal v1.0

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.

Provides
set-equal
Source Code
 
map-product v1.0

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.

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
Source Code
 
iota v1.0

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.

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
Source Code