An AbstractFunction is an object which responds to a set of messages that represent mathematical functions. Subclasses override a smaller set of messages to respond to the mathematical functions.
The intent is to provide a mechanism for functions that do not calculate values directly but instead compose structures for calculating (lazy evaluation).
Function, Pattern, Stream and UGen are subclasses of AbstractFunction. For example, if you multiply two UGens together the receiver responds by returning a new instance of class BinaryOpUGen which has the two operands as inputs.
For an overview of common operators, see Operators, for specific examples, see also e.g. Function, UGen, Pattern. To see which classes implement a specific method, see that method in the generated Methods overview.
The following messages return an object which represents a delayed unary operation, i.e. an operation on one object. For example, the reciprocal of a function will result in a new function that, when called, returns the reciprocal of the evaluation of the operand.
All of the following messages send the message composeUnaryOp to the receiver with the unary message selector as an argument. See UnaryOpFunction.
Bitwise integer negation.
Returns a function that returns -1 if receiver returns a negative number, 1 if positive, and 0 if zero.
Returns e to the power of this.
Converts midinote into cycles per seconds (Hz).
Converts cycles per seconds (Hz) into midinote.
The following messages return an object which represents a delayed binary operation, i.e. an operation between two objects. For example, adding two functions will result in a new function that, when called, adds the results of the evaluation of the two operands.
All of the following messages send the message composeBinaryOp to the receiver with the binary message selector and the second operand as arguments. See: BinaryOpFunction.
// Add two Patterns
// Add two NodeProxies
(a * b) + a
((a*b) + a + b)
(a * a * b)
((a*a *b) - (a*b*b))
(a*a) - (b*b)
(a*a) + (b*b)
(a - b) ** 2
(a + b) ** 2
(a - b).abs
absolute difference in modulo arithmetics.
0 when b <= 0, a*b when b > 0
a * b when a < 0, otherwise a.
clips receiver to +/- aNumber
Returns the difference of the receiver and its clipped form.
The following messages return an object which represents a delayed n-ary operation, i.e. an operation between several objects (often three). For example, rescaling a function with linlin will result in a new function that, when called, scales the results of the evaluation of all operands.
All of the following messages send the message
composeNAryOp to the receiver with the binary message selector and the other operands as arguments. See NAryOpFunction.
Interface that allows us to combine selectors (Symbols) and Functions. Sends valueArray(args) to this.
the result of sending the value(for) message to this.
Sample a function.
Sample the function with n points, in the range [from, to], and plot it in a Plotter. Returns a Plotter.
Number of values displayed in the plot window (500 by default).
Minimum value passed to the function.
Maximum value passed to the function.
When unary, binary or n-ary operators are applied to an abstract function, it returns an object that represents this operation, without evaluating the function: UnaryOpFunction, BinaryOpFunction, NAryOpFunction. Note that different subclasses like Pattern or UGen have their own composition scheme analogous to the one of AbstractFunction itself. For more about functions, see Function.
>=automatically perform function composition, as does
*in the example above.
Equality comparisons have two possible meanings: to compare the objects as they exist right now, or a composite operator that will evaluate the operands in the future and check the equality of those results. Both are needed at different times, and are supported by different operators:
== for an immediate equality check (which always returns a Boolean result), or
|==| for a "lazy" equality operator to be performed later.