4.2. pure operators

The semantics of each operator with regard to its input and output result kinds vary. However there is a large set of operators that share common semantics. These Operators are called Pure Operators and identified as such in documentation and reference.

Pure Ops only change when any of their inputs change and are often equivalent to a pure mathematical function. The inputs of a Pure Op can be mixed between all kinds of results, subject to the following rules:

The input and output types are defined by the concrete Op.

As an example, let’s consider math/+:

(import* math time)

(trace (+ 1 2 3))
(trace (+ 1 2 (lfo 2)))
(trace (+ 1 2 (every 1 3)))
(trace (+ 1 (lfo 2) (every 1 3)))
(+ num= num= num=) → num=
trace (+ 1 2 3): <num= 6>

(+ num= num= num~) → num~
trace (+ 1 2 (lfo 2)): <num~ 4.0>
trace (+ 1 2 (lfo 2)): <num~ 3.9882585630406>

(+ num= num= num!) → num!
trace (+ 1 2 (every 2 3)): <num! 6>
trace (+ 1 2 (every 2 3)): <num! 6>

(+ num= num~ num!) → num!
trace (+ 1 (lfo 2) (every 2 3)): <num! 4.9950529446967>
trace (+ 1 (lfo 2) (every 2 3)): <num! 4.9950529446967>

Sometimes a Pure Op will require additional constraints on the kinds of some of its inputs. These will be specified in the documentation.