Quickutilβ

Lisp utilities on demand

Fork me on GitHub
search

There are 43 utilities.

positivep v1.0

Check if n is positive.

Provides
positivep
Source Code
 
negativep v1.0

Check if n is negative.

Provides
negativep
Source Code
 
non-negative-p v1.0

Check if n is non-negative.

Provides
non-negative-p
Source Code
 
non-positive-p v1.0

Check if n is non-positive.

Provides
non-positive-p
Source Code
 
non-zero-p v1.0

Check if n is non-zero.

Provides
non-zero-p
Source Code
 
digit-count v2.0

Compute the number of digits in the non-negative integer n in base base. By default, the base is 10.

Provides
digit-count
Source Code
 
range-product v1.0

Compute lower * (lower+1) * ... * (upper-1) * upper.

Provides
range-product
Source Code
 
factorial v1.0

Compute the factorial of n, where n! = 1 * 2 * ... * n.

Provides
factorial
Requires
range-product
Source Code
 
binomial-coefficient v1.0

Binomial coefficient of n and k.

Provides
binomial-coefficient
Requires
factorial, range-product
Source Code
 
mulf v1.0

A modifying version of multiplication, similar to incf.

Provides
mulf
Source Code
 
divf v1.0

A modifying version of division, similar to decf.

Provides
divf
Source Code
 
half v1.0

Compute half of x.

Provides
half
Source Code
 
double v1.0

Compute double x.

Provides
double
Source Code
 
square v1.0

Compute the square of x.

Provides
square
Source Code
 
cube v1.0

Compute the cube of x.

Provides
cube
Source Code
 
digits v1.0

Return a list of the digits of the non-negative integer n in base base. By default, decimal digits are returned.

The order of the digits is such that the kth element of the list refers to the coefficient of base^k. In other words, given the resulting list

(c0 c1 c2 ... ck) 

the following identity holds:

n = c0 + c1*base + c2*base^2 + ... + ck*base^k. 
Provides
digits
Source Code
 
nth-digit v1.0

Get the nth digit in a rational number number in base base. If n is positive, it refers to digits to the left of the decimal point, and if negative, to the right. The digits of a negative number match that of its positive counterpart.

Provides
nth-digit
Source Code
 
bit-vector-integer v1.0

Convert a bit vector bv to a positive integer. The bits of the integer are ordered from most significant to least significant, unless least-significant-first is true.

Provides
bit-vector-integer
Source Code
 
integer-bit-vector v1.0

Convert a positive integer n to a bit vector. The least significant bits will be first if least-significant-first is true.

Provides
integer-bit-vector
Source Code
 
primes-below v1.0

Return a sorted list of all primes below an integer n.

Examples:

(primes-below 13) => (2 3 5 7 11)  
(primes-below -1) => NIL 
Provides
primes-below
Source Code
 
sec v1.0

Compute the secant of a number z.

Provides
sec
Source Code
 
csc v1.0

Compute the cosecant of a number z.

Provides
csc
Source Code
 
cot v1.0

Compute the cotangent of a number z.

Provides
cot
Source Code
 
asec v1.0

Compute the arcsecant of a number z.

Provides
asec
Source Code
 
acsc v1.0

Compute the arccosecant of a number z.

Provides
acsc
Source Code
 
acot v1.0

Compute the arccotangent of a number z.

Provides
acot
Source Code
 
imaginary-i v1.0

The imaginary number i = sqrt(-1).

Provides
imaginary-iii
Source Code
 
exponential-e v1.0

The exponential number e = 2.71828....

Provides
exponential-eee
Source Code
 
map-combinations v1.0

Calls function with each combination of length constructable from the elements of the subsequence of sequence delimited by start and end. start defaults to 0, end to length of sequence, and length to the length of the delimited subsequence. (So unless length is specified there is only a single combination, which has the same elements as the delimited subsequence.) If copy is true (the default) each combination is freshly allocated. If copy is false all combinations are eq to each other, in which case consequences are specified if a combination is modified by function.

Provides
map-combinations
Requires
ensure-function
Source Code
 
map-permutations v1.0

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

Provides
map-permutations
Requires
map-combinations
Source Code
 
map-derangements v1.0

Calls function with each derangement of the subsequence of sequence denoted by the bounding index designators start and end. Derangement is a permutation of the sequence where no element remains in place. sequence is not modified, but individual derangements are eq to each other. Consequences are unspecified if calling function modifies either the derangement or sequence.

Provides
map-derangements
Source Code
 
extremum v1.0

Returns the element of sequence that would appear first if the subsequence bounded by start and end was sorted using predicate and key.

extremum determines the relationship between two elements of sequence by using the predicate function. predicate should return true if and only if the first argument is strictly less than the second one (in some appropriate sense). Two arguments x and y are considered to be equal if (funcall predicate x y) and (funcall predicate y x) are both false.

The arguments to the predicate function are computed from elements of sequence using the key function, if supplied. If key is not supplied or is nil, the sequence element itself is used.

If sequence is empty, nil is returned.

Provides
extremum
Requires
ensure-function
Source Code
 
clamp v1.0

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.

Provides
clamp
Source Code
 
gaussian-random v1.0

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.

Sufficiently positive min or negative max will cause the algorithm used to take a very long time. If min is positive it should be close to zero, and similarly if max is negative it should be close to zero.

Provides
gaussian-random
Source Code
 
lerp v1.0

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

Provides
lerp
Source Code
 
mean v1.0

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

Provides
mean
Source Code
 
median v1.0

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

Provides
median
Requires
copy-sequence
Source Code
 
variance v1.0

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.

Provides
variance
Requires
mean
Source Code
 
standard-deviation v1.0

Standard deviation of sample. Returns the biased standard deviation if biased is true (the default), and the square root of the unbiased estimator for variance if biased is false (which is not the same as the unbiased estimator for standard deviation). sample must be a sequence of numbers.

Provides
standard-deviation
Requires
variance
Source Code
 
maxf v1.0

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

Provides
maxf
Source Code
 
minf v1.0

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

Provides
minf
Source Code
 
subfactorial v1.0

Subfactorial of the non-negative integer n.

Provides
subfactorial
Source Code
 
count-permutations v1.0

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

Provides
count-permutations
Requires
range-product
Source Code