API for the calc
module of formform
.
API for the `calc` module of `formform`.
(char->const c)
(char->const sort-code c)
Coerces a char
to a corresponding constant
.
Coerces a `char` to a corresponding `constant`.
(chars->dna dna-seq)
(chars->dna sort-code dna-seq)
Converts a seqable?
of chars to formDNA.
Note that nuim-code
is the default ordering. If a different sort-code
is specified, digits
will be reordered to match the code.
Converts a `seqable?` of chars to formDNA. Note that `nuim-code` is the default ordering. If a different `sort-code` is specified, `digits` will be reordered to match the code.
Comparator for constants using the default nuim-code
.
Comparator for constants using the default `nuim-code`.
(const->digit c)
(const->digit sort-code c)
Converts a constant
to a digit
corresponding to an optional sort-code
or the default nuim-code
.
Converts a `constant` to a `digit` corresponding to an optional `sort-code` or the default `nuim-code`.
Checks if the argument is a valid constant.
Checks if the argument is a valid constant.
(digit->const n)
(digit->const sort-code n)
Converts a digit to its corresponding constant representation.
Converts a digit to its corresponding constant representation.
(digits->dna dna-seq)
(digits->dna sort-code dna-seq)
Converts a seqable?
of digits (as string/char or integer) to formDNA.
Note that nuim-code
is the default ordering. If a different sort-code
is specified, digits
will be reordered to match the code.
Converts a `seqable?` of digits (as string/char or integer) to formDNA. Note that `nuim-code` is the default ordering. If a different `sort-code` is specified, `digits` will be reordered to match the code.
(dna->digits dna)
(dna->digits sort-code dna)
Converts formDNA to a sequence of digits corresponding to a sort-code
.
Note that nuim-code
is the default ordering. If a different sort-code
is specified, dna
will be reordered to match the code.
Converts formDNA to a sequence of digits corresponding to a `sort-code`. Note that `nuim-code` is the default ordering. If a different `sort-code` is specified, `dna` will be reordered to match the code.
(dna->vdict dna)
(dna->vdict opts dna)
Generates a vdict from a given dna.
sorted?
defaults to false since sorting large vspace dimensions can be expensiveGenerates a vdict from a given dna. * optional `sorted?` defaults to false since sorting large vspace dimensions can be expensive
(dna->vmap dna)
(dna-dimension xs)
Calculates the dimension of a formDNA
/dna-seq
(corresponds to the number of variables in a FORM). The length of a dna-seq
is 4^d for its dimension d.
Calculates the dimension of a `formDNA`/`dna-seq` (corresponds to the number of variables in a FORM). The length of a `dna-seq` is 4^d for its dimension d. * the input sequence can have any type of elements
(dna-perspectives dna)
(dna-perspectives opts dna)
Given a formDNA, generates all of its permutations and returns a map from permuted term order to the corresponding formDNA.
Given a formDNA, generates all of its permutations and returns a map from permuted term order to the corresponding formDNA.
(equal-dna & dnas)
Equality check for formDNA. Two formDNAs are considered equal, if they contain the same constants in the same order. Stricter than equiv-dna
, where permutations are considered equal.
Equality check for formDNA. Two formDNAs are considered equal, if they contain the same constants in the same order. Stricter than `equiv-dna`, where permutations are considered equal.
(equiv-dna & dnas)
Equivalence check for formDNA. Two formDNAs are considered equivalent, if they belong to the same equivalence-class of dna-perspectives
(i.e. if they are permutations of each other).
Equivalence check for formDNA. Two formDNAs are considered equivalent, if they belong to the same equivalence-class of `dna-perspectives` (i.e. if they are permutations of each other).
(expand-dna-seq dna-seq ext-dim)
(expand-dna-seq dna-seq dim ext-dim)
Expands a dna-seq
to a given target dimension by repeating elements.
Note: dna-seq
can have any type of elements (not only constants)
Expands a `dna-seq` to a given target dimension by repeating elements. Note: `dna-seq` can have any type of elements (not only constants)
(filter-dna dna vpoint)
Filters a dna
by selecting specific parts corresponding to a given vpoint
, which acts as a coordinate vector in its value space.
:_
to indicate a variable selectionFilters a `dna` by selecting specific parts corresponding to a given `vpoint`, which acts as a coordinate vector in its value space. * use holes `:_` to indicate a variable selection
(inv & consts-or-dnas)
Inverts the value of a every constant in a formDNA.
Inverts the value of a every constant in a formDNA.
(make-compare-consts sort-code)
Given a sort-code
(try calc.nuim-code
or calc.nmui-code
), returns a comparator function to sort single constants, formDNA or arbitrary sequences of constants (can be mixed).
Given a `sort-code` (try `calc.nuim-code` or `calc.nmui-code`), returns a comparator function to sort single constants, formDNA or arbitrary sequences of constants (can be mixed). * can also compare map-entries by keys of comparable types
(make-dna & xs)
Creates a formDNA from arguments, which may be valid chars, keywords, integers or sequences thereof.
Creates a formDNA from arguments, which may be valid chars, keywords, integers or sequences thereof. * valid chars are: \n \u \i \m (upper- or lowercase) and \0 \1 \2 \3 * valid integers are: 0 1 2 3 * valid keywords are: :N :U :I :M * total argument count (including count of sequence args) must match a valid formDNA length, which is 4^d, where d is a natural number
(permute-dna dna perm-order)
(permute-dna opts dna perm-order)
(rand-dna dim)
(rand-dna dim elems)
Generates a random formDNA/dna-seq
of dimension dim
. A vector of 4 custom elements can be provided as a second argument.
Generates a random formDNA/`dna-seq` of dimension `dim`. A vector of 4 custom elements can be provided as a second argument.
(rand-vpoint)
(rand-vpoint dim)
Generates a random vpoint either as an infinite lazy seq or with given dimension dim
.
Generates a random vpoint either as an infinite lazy seq or with given dimension `dim`.
(reduce-dna-seq dna-seq)
(reduce-dna-seq terms dna-seq)
Reduces a dna-seq
by eliminating redundant/contingent terms.
[terms dna-seq]
, where terms
is a sequence that represents the remaining terms after reductionterms
sequence of any kind of items that will be used instead of the default arithmetic sequence [0 1 2 …]
to represent each term (length has to match the formDNA dimension)Note: dna-seq
can have any type of elements (not only constants)
Reduces a `dna-seq` by eliminating redundant/contingent terms. * returns a tuple `[terms dna-seq]`, where `terms` is a sequence that represents the remaining terms after reduction * takes an optional `terms` sequence of any kind of items that will be used instead of the default arithmetic sequence `[0 1 2 …]` to represent each term (length has to match the formDNA dimension) Note: `dna-seq` can have any type of elements (not only constants)
(rel & consts-or-dnas)
Relates the values of 2 constants in a formDNA to each other.
Relates the values of 2 constants in a formDNA to each other.
(reorder-dna-seq dna-seq sort-code-from sort-code-to)
Reorders given formDNA/dna-seq
from sort-code-from
to sort-code-to
.
Note:
dna-seq
can have any type of elements (not only constants)Reorders given formDNA/`dna-seq` from `sort-code-from` to `sort-code-to`. Note: * `dna-seq` can have any type of elements (not only constants) * does NOT change the encoding of the elements, just their ordering
Variable constant (like a hole/placeholder)
Variable constant (like a hole/placeholder)
(vdict vpoint->result)
(vdict opts vpoint->result)
Generates a vdict given a map vpoint->result (result is a constant).
vp->r
, the remaining results will be filled with :N or a given default constantsorted?
defaults to false since sorting large vspace dimensions can be expensiveGenerates a vdict given a map vpoint->result (result is a constant). * if the corresponding vspace is not a subset of the set of keys from `vp->r`, the remaining results will be filled with :N or a given default constant * optional `sorted?` defaults to false since sorting large vspace dimensions can be expensive
(vdict->vmap vdict)
Generates a vmap from a given vdict.
Generates a vmap from a given vdict.
(vspace dim)
(vspace sort-code dim)
Generates a vspace of dimension dim
, optionally with custom sort-code
.
Generates a vspace of dimension `dim`, optionally with custom `sort-code`. * returns a lazy-seq which may be too memory-expensive to fully realize for dimensions greater than 11 (> 200 Mio. elements in total!)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close