# kronoslang/core

### Namespaces

1. #### Algorithm

Generate algorithmic circuits from data structures.

2. #### Approx

Numerical tricks to compute approximations of mathematical functions efficiently, with some loss of precision.

3. #### Complex

Defines complex-number type and arithmetic.

4. #### Control

Tools for control signals. Edge detectors, signal smoothers and hold circuits.

5. #### Envelope

Make musical control envelopes out of trigger and gate signals.

6. #### Filter

Audio filters to shape the frequency response

7. #### Function

Utilities to compose functions and adjust their behavior

8. #### Gen

Elementary signal generator system

9. #### Math

Mathematical functions, for hyperbolic transcendentals and polynomials.

## Global namespace

`Audio-Cycle(init func)`

Route the output of 'func' back to its argument through a unit delay. The feedback is upsampled to audio rate. The unit delay is initialized to 'init'

`Average(numbers...)`

Compute the average of `numbers...`

`Compose(fn-list...)`

Composes functions in a nil-terminated 'fn-list' into a chain, which passes the initial argument through the entire chain.

`Control-Cycle(init func)`

Route the output of 'func' back to its argument through a unit delay. The feedback is upsampled to control rate. The unit delay is initialized to 'init'

`Interval-of(sig)`

Retrieve the sampling interval of 'sig' in seconds

`Juxtapose(fn-list...)`

Composes a function that passes its argument to all functions in the nil-terminated 'fn-list', returning the results in a list.

`Nth(index set...)`

Takes the 'index'th element of 'set'.

`Pair(fst rst)`

Incorporate 'fst' and 'rst' as the first and second halves of a pair.

`Product(numbers...)`

Compute the product of `numbers...`.

`Rate-of(sig)`

Retrieve the sampling rate of 'sig' in Herz

`Rest(pair)`

Destructure 'pair' and return the second half.

`Sequence(head tail...)`

construct a sequence with 'head' followed by the data in 'tail...'

`Sum(numbers...)`

Compute the sum of `numbers...`.

## Algorithm

Generate algorithmic circuits from data structures.

`Accumulate(func:Function! set...)`

Produces a list where each element is produced by applying 'func' to the previously produced element and an element from 'set'.

`Choose(truth when-true when-false)`

Choose either 'when-true' or 'when-false' based on 'truth'. The branches should have equal type.

`Concat(as bs)`

Prepends the list 'as' to the list 'bs'

`Count(n:Constant!)`

Makes a list of invariant constants from #1 to n

`Count(n:Constant! start)`

Makes a list of 'n' elements, counting up from 'start'

`Count(n:Constant! start step)`

Makes a list of 'n' elements, counting up from 'start' in 'step's.

`Every(predicate:Function! set...)`

#true if all elements in 'set' are true according to 'predicate'.

`Expand(count:Constant! iterator seed)`

Produces a list of 'count' elements, starting with 'seed' and generating the following elements by applying 'iterator' to the previous one.

`Filter(predicate:Function! set)`

Evaluates 'predicate' for each element in 'set', removing those elements for which nil is returned.

`Find-Max(set...)`

Returns the index to the element in `set...` that has the greatest value. Returns the pair `(index value)`.

`Find-Max-With(pred:Function! set...)`

Returns the index to the element in `set...` that is the greatest according to a binary `pred`icate.

`Find-Min(set...)`

Returns the index to the element in `set...` that has the least value. Returns the pair `(index min-value)`.

`Flat-First(x)`

Returns the first element in 'x' regardless of its algebraic structure.

`Flatten(set...)`

Flatten any nested data structures, resulting in a flat list.

`Fold(func:Function! set...)`

Folds 'set' by applying 'func' to the first element of 'set' and a recursive fold of the rest of 'set'.

`Iterate(n:Constant! func:Function! x)`

Applies a pipeline of 'n' 'func's to 'x'.

`Map(func:Function! set...)`

Applies 'func' to each element in 'set', collecting the results in a new structurally similar set.

`Multi-Map(func:Function! sets...)`

Applies a polyadic 'func' to a tuple of corresponding elements in all of the 'sets'. The resulting set length corresponds to the smallest input set.

`Partition(N:Constant! set...)`

Partition `set...` into tuples with `N` elements each.

`Reduce(func:Function! set...)`

Applies a binary 'func' to combine the first two elements of a list as long as the list is more than one element long.

`Repeat(n:Constant! x)`

Makes a list of 'n' elements that have the value 'x'.

`Skip(N:Constant! set...)`

Remove `N` items from the beginning of `set...`

`Some(predicate:Function! set...)`

#true if some element in 'set' is true according to 'predicate'.

`Split(xs...)`

Splits the list `xs...` in half

`Take(N:Constant! set...)`

Take the first `N` items from the beginning of `set...`.

`Take-Last(N:Constant! xs)`

Take the last `N` items from the beginning of `set...`.

`Unzip(set...)`

Produces a pair of lists, by extracting the 'First' and 'Rest' of each element in 'set...'.

`Zip(as bs)`

Produces a list of pairs, with respective elements from 'as' and 'bs'.

`Zip-With(func:Function! as bs)`

Applies a binary 'func' to elements pulled from 'as' and 'bs', collecting the results.

`Zip3-With(func:Function! as bs cs)`

Applies a ternary 'func' to elements pulled from 'as', 'bs' and 'cs', collecting the results.

## Approx

Numerical tricks to compute approximations of mathematical functions efficiently, with some loss of precision.

`Cosine-Shape(x order)`

Provides a polynomial cosine shape around 0 with a half-period within the range [-0.5, 0.5], diverging rapidly outside those bounds. The precision is decided by `order`, an invariant constant.

`Fast:Cosh(p)`

Approximate the hyperbolic cosine

`Fast:Exp(p)`

Approximate the exponential function using the `Pow2` approximation

`Fast:Log(x)`

Approximate natural logarithm

`Fast:Log2(x)`

Approximate base-2 logarithm

`Fast:Pow(x p)`

Approximate `x^p` with the `Pow2` and `Log2` approximations.

`Fast:Pow2(x)`

Approximate power-of-two, as in `2^x`

`Fast:Sigmoid(x)`

Approximate the sigmoid saturation function

`Fast:Sinh(p)`

Approximate the hyperbolic sine

`Fast:Tanh(p)`

Approximate the hyperbolic tangent

`Faster:Cos-Period(x)`

Approximate cosine in the range [-Pi, Pi]

`Faster:Exp(p)`

Approximate the exponential function using the `Pow2` approximation

`Faster:Log(x)`

Approximate natural logarithm of `x`

`Faster:Log2(x)`

Approximate base-2 logarithm of `x`

`Faster:Pow(x p)`

Approximate power function, `x^p`, by using the approximations `Pow2` and `Log2` to compute `Pow2(p * Log2(x))`

`Faster:Pow2(x)`

Approximate power-of-two, as in `2^x`

`Faster:Sigmoid(x)`

Approximate the sigmoid saturation function

`Faster:Sin-Period(x)`

Approximate sine in the range [-Pi,Pi]

`Faster:Tan-Period(x)`

Approximate tanget in the range [-Pi/2, Pi/2]

`Faster:Tanh(p)`

Approximate the hyperbolic tangent

`Tanh(w)`

Fast hyperbolic tangent approximation; useful for soft saturation. From https://www.musicdsp.org/en/latest/Other/238-rational-tanh-approximation.html

## Audio

`File(path)`

Load a sound file at 'path', returning a tuple of (sample-rate frames function), where function samples the audio file at integer positions.

`Loop(path)`

Load a sound file at 'path', returning a tuple of (sample-rate function), where function samples the audio file at integer positions. The file is exposed as an infinite cyclic loop.

`Signal(sig)`

Upsample `sig` to the audio rate.

## Bitonic

`Sort(set...)`

Construct a bitonic sorting network whose output is the `set...` ordered in ascending natural order

`Sort-With(pred set...)`

Construct a bitonic sorting network whose output is the `set...` ordered according to `pred`icate. For example, ascending order is produced by `(<)` and descending by `(>)`.

## Complex

Defines complex-number type and arithmetic.

`Abs(c:Complex!)`

Computes the absolute value of complex 'c'.

`Abs-Square(c:Complex!)`

Computes the square of the absolute value of complex 'c'.

`Add(a:Complex! b:Complex!)`

`Conjugate(c:Complex!)`

Constructs a complex conjugate of 'c'.

`Cons(real:Real! img:Real!)`

Constructs a Complex number from 'real' and 'img'inary parts.

`Cons-Maybe(real img)`

Constructs a Complex number from 'real' and 'img', provided that they are real numbers.

`Div(z1:Complex! z2:Complex!)`

Divides complex 'z1' by complex 'z2'.

`Equal(z1:Complex! z2:Complex!)`

Compares the complex numbers 'z1' and 'z2' for equality.

`Mul(a:Complex! b:Complex!)`

Multiplies two complex numbers.

`Neg(z:Complex!)`

Negates a complex number 'z'.

`Polar(angle:Real! radius:Real!)`

Constructs a complex number from a polar representation: 'angle' in radians and 'radius'.

`Real/Img(c:Complex!)`

Retrieve Real and/or Imaginary part of a Complex number 'c'.

`Sub(a:Complex! b:Complex!)`

Substracts complex 'b' from 'a'.

`Unitary(angle:Real!)`

Constructs a unitary complex number at 'angle' in radians.

## Constraints

`Atom!(a)`

Matches when 'a' is an atom, a value that can not be further destructured.

`Condition!(v pred)`

Tests 'v'alue using 'pred'icate. If pred(v) is True, returns 'v', otherwise do not match.

`Constant!(a)`

Matches when 'a' is an invariant constant.

`Double-Precision!(dp)`

Matches when 'dp' is a double precision floating point number

`Function!(fn)`

Matches when 'fn' is callable

`Integer!(i)`

Matches when 'i' is a scalar integer

`Nil!(n)`

Matches when 'n' is nil

`Real!(r)`

Matches when 'r' is a scalar real number

`Scalar!(s)`

Matches when 's' is a scalar numeric value.

`Seq-Length!(s n)`

Matches when 's' is a sequence of at least 'n' elements

`Sequence!(p)`

Matches when 'p' can be destructured.

`Single-Precision!(sp)`

Matches when 'sp' is a single precision floating point number

`True!(t)`

Matches when 'n' is true

`Vector!(v)`

Satisfy constraint when 'v' is a vector

## Control

Tools for control signals. Edge detectors, signal smoothers and hold circuits.

`Edge+(sig)`

True when `sig` contains an upward edge

`Edge+-(sig)`

True when the value of `sig` changes

`Edge-(sig)`

True when `sig` contains a downward edge

`Sample-and-Hold(sig sample?)`

When `sample?` is not true, freeze the value of `sig`nal.

`Signal(sig)`

Resample `sig` to control rate (1/64 audio)

`Signal-Coarse(sig)`

Resample `sig` to coarse control rate (1/512 audio)

`Signal-Fine(sig)`

Resample `sig` to fine control rate (1/8 audio)

`Smooth(sig rate)`

Resamples 'sig'nal to control rate and applies a lowpass filter to reduce variations faster than 'rate' in Hertz.

`Smooth-Audio(sig rate)`

Resamples 'sig'nal to audio rate and applies a lowpass filter to reduce variations faster than 'rate' in Hertz.

`Smooth-Faster(sig rate)`

Resamples 'sig'nal to a finer control rate and applies a lowpass filter to reduce variations faster than 'rate' in Hertz.

`Smooth-Slower(sig rate)`

Resamples 'sig'nal to a coarse control rate and applies a lowpass filter to reduce variations faster than 'rate' in Hertz.

## Delay

`Allpass-Comb(sig num-samples feedback)`

Constructs a series combination of a feedforward and feedback comb filter sharing a delay line to create an allpass filter structure. The echo density is specified by `num-samples` and decay rate by `feedback`.

`Comb(sig num-samples feedback)`

Delays 'sig'nal by 'num-samples' ticks of its clock. 'num-samples' must be an invariant constant, such as #10. The delayed output is added back to the input signal, multiplied by 'feedback'

`Cons(sig max-delay)`

Constructs a dynamic delay line in the form of a function that can be evaluated to retrieve a delayed 'sig'nal. Delay line memory is allocated according to 'max-delay', which must be an invariant constant, such as #100, which corresponds to 100 ticks of the 'sig'nal clock. 'Eval'uate the (closure) output of this function with a parameter specifying the desired delay up to 'max-delay' frames of 'sig'nal. The output can be enhanced by wrapping it in interpolation, or altering the time base, such as 'Compose( Function:Wrap-Hermite(delay-fn) (* sample-rate))' which would result in a 3rd order interpolated delay with the parameter in seconds.

`Dynamic-Delay(sig delay-time buffer-size)`

Delays 'sig'nal by 'delay-time' seconds, which can vary up to 'buffer-size' ticks of 'sig'nal clock. The delayed signal supports fractional delays with 3rd degree polynomial interpolation, making this delay suitable for modulating 'delay-time'.

`Dynamic-Delay(sig delay-time buffer-size feedback-fn)`

Delays 'sig'nal by 'delay-time' seconds, which can vary up to 'buffer-size' ticks of 'sig'nal clock. The delayed signal supports fractional delays with 3rd degree polynomial interpolation, making this delay suitable for modulating 'delay-time'. Delayed output is added to the input signal processed via the 'feedback-fn', e.g. a damping filter or a feedback coefficient such as '(* 0.5)'.

`Sample-Delay(sig num-samples)`

Delays 'sig'nal for 'num-samples' ticks of its clock. 'num-samples' must be an invariant constant, such as #100.

`Sample-Delay(sig num-samples max-delay)`

Delays 'sig'nal for 'num-samples' ticks of its clock. 'num-samples' is dynamic and can vary up to 'max-delay', which must be an invariant constant..

`Static-Delay(sig delay-time buffer-size)`

Delays 'sig'nal by 'delay-time' seconds, which can vary up to 'buffer-size' ticks of 'sig'nal clock. The delayed signal is not interpolated, so this delay is best used with static 'delay-time'.

`Static-Delay(sig delay-time buffer-size feedback-fn)`

Delays 'sig'nal by 'delay-time' seconds, which can vary up to 'buffer-size' ticks of 'sig'nal clock. The delayed signal is not interpolated, so this delay is best used with static 'delay-time'. Delayed output is processed via the 'feedback-fn', e.g. a damping filter or a feedback coefficient such as '(* 0.5)' and added back to the input signal.

## Envelope

Make musical control envelopes out of trigger and gate signals.

`ADSR(gate attack decay sustain release)`

Generates a linear attack-decay-sustain-release envelope given a `gate` signal. The envelope proceeds towards the sustain phase while the gate is up. When the gate is down, the ADS-phase ends and the signal tends towards `0` in `release` seconds. Upward edges in `gate` reset the envelope to the beginning of the attack phase.

`AR(gate attack release)`

Generates a linear attack-release envelope given a 'gate' signal. The upward edge in 'gate' becomes a ramp of 'attack' seconds, and the downard edge is a ramp of 'release' seconds.

`BPF(gate segments...)`

Breakpoint function envelope with linear `segments...` given as a list of `(x y)` where `x` is an interval in seconds relative to the start of the envelope. The envelope ticks at either the control rate or the signal rate of `gate`, whichever is higher. OUTPUT: (x y) interpolated coordinates along the bpf

`Linear(gate segments...)`

Envelope with linear `segments...`, given as a list of pairs in the format `(value seconds)`. The generator will produce linear segments sequentially towards the next `value` with the duration in `seconds`. In case the gate signal does not have a regular clock, it is upsampled to the control rate.

`Release(gate duration)`

Slows down the release phase of the `gate` signal to ramp down over `duration` seconds. In case the gate signal does not have a regular clock, it is upsampled to the control rate.

`Slew(sig rate+ rate-)`

Limits the slew of `sig`nal to at most `slew+` and at least `slew-` for each clock period of `sig`nal.

## Filter

Audio filters to shape the frequency response

`Allpass(sig coef)`

A second-order allpass filter

`Biquad(sig a0 a1 a2 b1 b2)`

Two-pole, two-zero filter with forward coefficients 'a0' 'a1' and 'a1', and feedback coefficients 'b1' and 'b2'. The output comes from the difference equation y[t] = a0 x[t] + a1 x[t-1] + a2 x[t-2] - b1 y[t-1] - b2 y[t-2]

`Convolve(sig coefs)`

Convolves 'sig'nal with a FIR filter consisting of coefficients in 'coefs'. The length of the list determines the order of the filter. The coefficients are arranged from low to high order.

`DC(sig)`

Remove any DC offset from 'sig'nal

`Downsample(sig)`

Half-band filter 'sig' and drop every other sample. Please note that the output will tick at half the rate of 'sig'.

`Highpass(sig cutoff resonance)`

Resonant highpass filter. Attenuate frequencies below 'cutoff'. From https://www.musicdsp.org/en/latest/Filters/38-lp-and-hp-filter.html

`Integrate(sig feedback)`

Integrate incoming 'sig'nal. For lossless integration, use 'feedback' of 1. Smaller feedback coefficients will produce a leaky integrator.

`Lowpass(sig cutoff resonance)`

Resonant lowpass filter. Attenuate frequencies above 'cutoff'. From https://www.musicdsp.org/en/latest/Filters/38-lp-and-hp-filter.html

`Lpf6(sig cutoff)`

Filter 'sig'nal with a simple one-pole 6dB/octave lowpass slope. The cutoff is specified in Hertz.

`Pole(sig pole)`

First-order filter with a single `pole`

`Pole-Zero(sig pole zero)`

First-order filter with one `pole` and one `zero`.

`Polyphase(sig a b)`

Send 'sig'nal through two allpass filter cascades with coefficient lists given by 'a' and 'b'.

`Resonator(sig freq bw)`

Filters 'sig'nal to produce a resonant peak at 'freq'uency, with a bandwidth of 'bw' in Hertz.

`SVF(sig cutoff resonance)`

Double-sampled stable state-variable filter. Filter operates at the 'cutoff' frequency and 'resonance' is in range [0,1]. from https://www.musicdsp.org/en/latest/Filters/92-state-variable-filter-double-sampled-stable.html. OUTPUTS: (notch lowpass highpass bandpass peaking)

`Tone(sig cutoff)`

Filter 'sig'nal with a simple one-pole 6dB/octave lowpass slope. The cutoff range is [0,1] for closed or fully open.

`Upsample(sig)`

Double-samples 'sig' by inserting zeroes and halfband-filtering. Please note that the output will tick at twice the rate of 'sig'.

`Zero(sig zero)`

First-order filter with a single `zero`

## Function

Utilities to compose functions and adjust their behavior

`Compose(fns...)`

Composes the functions in 'fns...' in a chain. The initial argument is passed to the last function in the list, and its return value is passed as the argument to the second-last function. Similiar transformation is performed by each function on the list, from back to front.

`Juxtapose(fns...)`

Composes a function that passes its argument to all functions in `fn-list`, returning the results in a list.

`Pipeline(fns...)`

Composes the functions in `fns...` in a chain. The initial argument is transformed by each successive function and used as the argument to the next function, in sequence.

`Table(xs...)`

Given a list `xs...`, returns a function that, given an argument `i`, returns the `i`:th element in `xs...`.

`Table-Cyclic(xs...)`

Given a list `xs...`, returns a function that, given an argument `i`, returns the `i`:th element in `xs...`. The list is extended in an infinite cycle, both beyond the count of the original elements and also below index 0.

`Table-Period(xs...)`

Given a list of `xs..., returns a function that cycles through them during each interval between integers with linear interpolation. Suitable for waveshaping a phasor.

`Table-Period-Smooth(xs...)`

Given a list of `xs..., returns a function that cycles through them during each interval between integers with polynomial Hermite interpolation. Suitable for waveshaping a phasor.

`Wrap-Hermite(fn)`

Wraps `fn` in Hermite interpolation: returns a function that, when called with argument `x`, calls `fn` with four sample points ranging from `x - #1` to `x + #2`, and interpolates between the values at `x` and `x + #1` according to the fraction of `x`. The additional sample points are used to produce a smoother curve.

`Wrap-LERP(fn)`

Wraps `fn` in linear interpolation: returns a function that, when called with argument `x`, calls `fn(x)` and `fn(x + #1)`, interpolating linearly between them, weighted by the fraction of `x`. This can produce a linear breakpoint function from a discrete-valued, 'stair-case' `fn`.

## Gen

Elementary signal generator system

`Cycles-per-Sample(freq)`

Converts 'freq'uency in herts to Cycles-per-Sample according to the firing rate of 'Gen:Signal'. The output is also resampled according to 'Gen:Signal'.

`Faster(factor fn args...)`

Function 'fn' is evaluated in a context where all the signal sources in the Gen package update at a rate that is faster by 'factor' in comparison to the current one.

`Interval()`

Outputs the 'sampling-interval' of the Generators in seconds

`Noise(seed)`

Generate a white noise sound from a seed value that should be close to but not exactly 0.5.

`Osc(shape-fn freq)`

Produces a signal by waveshaping the output of a phasor at 'frequency' by 'shape-fn', such as in Osc(440 Shape:Triangle). The wave-shaped output from the range [0,1] is rescaled to the bipolar range of [-1,1].

`Osc(shape-fn freq maximum)`

Produces a signal by waveshaping the output of a phasor at 'frequency' by 'shape-fn', such as in Osc(440 Shape:Triangle). The output is scaled to the unipolar range of [0, maximum]

`Osc(shape-fn freq minimum maximum)`

Produces a signal by waveshaping the output of a phasor at 'frequency' by 'shape-fn', such as in Osc(440 Shape:Triangle). The output is scaled to the range of [minimum, maximum]

`Oversample(num-stages fn args...)`

Within function 'fn', double the rate of 'Gen:Signal' 'num-stages' times. Each stage output is equipped with a halfband filter and the signal rate is decimated by 2. As a result, any 'Gen:Signal' clock at the output will correspond to the normal rate.

`Phasor(freq)`

Generates a periodic ramp signal in the range [0,1]. The period of the ramp is 'freq' Hz, sampled at the clock generated by 'Gen:Signal'.

`Pulse(freq width)`

Produces a bipolar naive pulse waveform with 'width' in the range of [0,1].

`Pulse(freq width offset)`

Produces a bipolar naive pulse waveform with 'width' in the range of [0,1], with a phase offset of [0,1] in proportion to the waveform period.

`Ramp(trig rate)`

Produces a signal that starts from zero and changes linearly, at `rate` per second. When `trig` signal has an upward edge, the ramp is reset to zero.

`Random(seed)`

Generate random deviation in range [0,1] at the audio rate.

`Random(seed deviation)`

Generate random deviation in range [-deviation,deviation] at the audio rate.

`Random(seed low-bound high-bound)`

Generate random deviation in range [low-bound, high-bound] at the audio rate.

`Rate()`

Outputs the 'sampling-rate' of the Generators

`Saw(freq)`

Produces a bipolar naive sawtooth waveform with upward edges

`Saw(freq offset)`

Produces a bipolar naive sawtooth waveform with upward edges and a phase offset of [0,1] in proportion to the waveform period.

`Saw-(freq)`

Produces a bipolar naive sawtooth waveform with downward edges

`Saw-(freq offset)`

Produces a bipolar naive sawtooth waveform with downward edges and a phase offset of [0,1] in proportion to the waveform period.

`Shape:Pulse(width)`

Makes a waveshaper for a naive rectangular pulse with width ranging from 0 to 1.

`Shape:Saw(phase)`

Converts a phasor output to a naive unipolar sawtooth wave with upward edges.

`Shape:Saw-(phase)`

Converts a phasor output to a naive unipolar sawtooth wave with downward edges

`Shape:Triangle(phase)`

Converts a phasor output to a naive unipolar triangular wave

`Signal(sig)`

Acts as a signal clock generator for all the generators. By default, 'sig' is resampled to the audio clock. You can use 'With-Binding' to override the signal clock. For example, `With-Binding(":Gen:Signal" Control:Signal { Gen:Sin(440) })` generates a control rate sinusoidal oscillator

`Sin(freq)`

Produces a polynomial sinusoid waveform.

`Sin(freq offset)`

Produces a polynomial sinusoid waveform with a phase 'offset' against a cosine wave, measured in periods of the waveform.

`Sin-Waveguide(freq)`

Audio rate sinusoid generater based on a digital waveguide. It is very pure and CPU-efficient, but not for audio-rate modulation such as FM.

`Slower(factor fn args...)`

Function 'fn' is evaluated in a context where all the signal sources in the Gen package update at a rate that is slower by 'factor' in comparison to the current one.

`Tri(freq)`

Produces a bipolar naive triangular waveform

`Tri(freq offset)`

Produces a bipolar naive triangular waveform with a phase offset of [0,1] in proportion to the waveform period.

## Math

Mathematical functions, for hyperbolic transcendentals and polynomials.

`Binomial-Coef(n k:Constant!)`

computes binomial coefficient for the pair `(n k)`

`Clamp(x low-bound high-bound)`

Clamp the values of 'x' so that it will not go below 'low-bound' or above 'high-bound'

`Copy-Sign(value sign)`

changes the sign of 'value' to match 'sign'

`Cosh(x)`

Computes the hyperbolic cosine of 'x'

`Coth(x)`

Computes the hyperbolic cotangent of 'x'

`Csch(x)`

Computes the hyperbolic cosecant of 'x'

`Factorial(n:Constant!)`

computes the factorial of 'n'

`Hermite-Interpolation(h x-1 x0 x1 x2)`

Hermite interpolation between 'x0' and 'x1' as 'h' goes from 0 to 1, with further control points 'x-1' and 'x2' referring to past and future points.

`Horner-Scheme(x coefficients)`

Evaluates a polynomial described by the set of 'coefficients' that correspond to powers of 'x' in ascending order. The evaluation is carried out according to the Horner scheme.

`Linear-Interpolation(h x0 x1)`

Interpolate linearly between x0 an x1 as h ranges from 0 to 1.

`Mix(mix a b)`

Weighted average of 'a' and 'b' according to ratio, so that 0 corresponds to fully 'a', 1 to 'b' and 0.5 to an equal mix.

`Sech(x)`

Computes the hyperbolic secant of 'x'

`Sinh(x)`

Computes the hyperbolic sine of 'x'

`Tan(x)`

Computes the tanget of 'x'

`Tanh(x)`

Computes the hyperbolic tangent of 'x'

## Vector

`Broadcast-To(vector scalar)`

Result is structurally similar to 'vector', but all elements are 'scalar'.

`Concat(a b...)`

Concatenates elements in vectors, tuples or scalars into a vector.

`Cons(elements...)`

Combine 'elements...' into a vector

`Explode(v)`

Separate elements in vector 'v'

`Horizontal(fn v)`

Apply binary operator 'fn' horizontally to reduce the vector to a single element. For example, to add all vector elements, use `Horizontal(Add vector)`

`Indices(count)`

Produces an index vector with 'count' elements, starting from 0 and increasing by one.

`Indices(count start)`

Producs an index vector with 'count' elements, starting from 'start' and increasing by one.

`Indices(count start step)`

Produces an index vector with 'count' elements, starting from 'start' and increasing by 'step'.

`Ones(count)`

Produces a vector with 'count' elements, each set to 1.

`Repeat(count value)`

Produces a vector with 'count' elements, each set to 'value'.

`Split(vector)`

Splits `vector` into a tuple of two smaller vectors half the width. If the original width is odd, the first vector will be smaller.

`Vectorize(elements...)`

If `elements...` is a tuple, turn it into a vector. Otherwise return as-is.

`Width(v)`

Number of elements in vector 'v'