variadic¶
daamath formalizes the extension of a function into variadic inputs. the variadic extension F(X) of a function f(x) is a function (closed on a certain domain) that takes multiple inputs in a structure and collapses them into a smaller output. for this to be possible, f(x) must produce lesser outputs than there are inputs, and the output must be operable with the remaining inputs (that entails, usually, f(x) being the same kind as x. if [1,2,3] was suddenly collapsed to [True, 3], then we cannot collapse it further. that is invalid).
usually, this is a closed associative binary (and often commutative) function, whose variadic extension takes in a sequence of inputs and collapses from the left (left-fold, similar to python's functools.reduce)
vadd¶
variadic extension of add. also known as summation
vmul¶
variadic extension of mul. also known as product
vand¶
variadic extension of and. also known as an 'all' gate
vor¶
variadic extension of or. also known as an 'any' gate
vxor¶
variadic extension of xor. checks if parity is even
vnxor¶
variadic extension of xnor. checks if parity is odd
vmin¶
variadic extension of min — the infimum under natural ordering (it is usually presented as its variadic version but it is primitively a binary function)
vmax¶
variadic extension of max — the supremum under natural ordering (it is usually presented as its variadic version but it is primitively a binary function)
vgcd¶
variadic extension of gcd — the infimum under divisibility ordering (it is usually presented as its variadic version but it is primitively a binary function)
vlcm¶
variadic extension of lcm — the supremum under divisibility ordering (it is usually presented as its variadic version but it is primitively a binary function)
notes¶
these variadic extensions are only valid in certain domains. this is already made clear but just keep in mind that an operator is not intrinsically varidically extensible. it is only extensible in the context of a certain domain.
some functions such as mean, median, mode were not extended because there is no primitive that they can be composed of. so they are not added here.
DAA! remember again (2026-04-30), the primitive functions take arguments flatly. but the variadic versions take one iterable as input (probably a sequence/1D vector). this should decide if max should be the variadic one (takes a vector as input) or the binary one (takes two arguments as input)
2026-04-30 0901 daa, why not instead make a function that takes in a vector and an operator, and applies the operator on the vector to collapse it?
because some of them can get specialized routines
but couldnt you implement those special routines in the function? if it detects that dm.max was taken in, it would use a special routine for that.
ah.. interesting. then i do want to let users write variadic(max, [1,2,3]) instead of vmax([1,2,3]). because then they can turn any binary primitive into a variadic version. ahh! thank you by the way. i also now realized that only functions that preserve type are valid for this.