SequenceableCollection is a subclass of Collection whose elements can be indexed by an Integer. It has many useful subclasses; Array and List are amongst the most commonly used.
Creates a Collection of the given size, the elements of which are determined by evaluation the given function. The function is passed the index as an argument.
size |
The size of the collection which is returned. If nil, it returns an empty collection. If an array of sizes is given, the resulting collection has the appropriate dimensions (see: *fillND). |
function |
The function which is called for each new element - the index is passed in as a first argument. The function be anything that responds to the message "value". |
Fill a SequenceableCollection with an arithmetic series.
Fill a SequenceableCollection with a geometric series.
Fill a SequenceableCollection with a fibonacci series.
size |
the number of values in the collection |
a |
the starting step value |
b |
the starting value |
Fill a SequenceableCollection with random values in the range minVal to maxVal.
Fill a SequenceableCollection with random values in the range -val to +val.
Fill a SequenceableCollection with random values in the range minVal to maxVal with a linear distribution.
Fill a SequenceableCollection with random values in the range minVal to maxVal with exponential distribution.
Fill a SequenceableCollection with the interpolated values between the start and end values.
synonym for ArrayedCollection: -clipAt.
synonym for ArrayedCollection: -wrapAt.
synonym for ArrayedCollection: -foldAt.
Return the first element of the collection.
Return the last element of the collection.
Place item at the first / last index in the collection. Note that if the collection is empty (and therefore has no indexed slots) the item will not be added.
Return the index of an item in the collection, or nil if not found. Elements are checked for identity (not for equality).
Return the index of something in the collection that equals the item, or nil if not found.
Return an array of indices of things in the collection that equal the item, or nil if not found.
Return the first index containing an item which is greater than item.
Return a new collection of same type as receiver which consists of all indices of those elements of the receiver for which function answers true
. The function is passed two arguments, the item and an integer index.
If you want to control what type of collection is returned, use -selectIndicesAs
Return a new collection of type class which consists of all indices of those elements of the receiver for which function answers true
. The function is passed two arguments, the item and an integer index.
Return a new collection of same type as receiver which consists of all indices of those elements of the receiver for which function answers false
. The function is passed two arguments, the item and an integer index.
If you want to control what type of collection is returned, use -rejectIndicesAs
Return a new collection of type class which consists of all indices of those elements of the receiver for which function answers false
. The function is passed two arguments, the item and an integer index.
Answer the index of the maximum of the results of function evaluated for each item in the receiver. The function is passed two arguments, the item and an integer index. If function is nil, then answer the maximum of all items in the receiver.
Answer the index of the minimum of the results of function evaluated for each item in the receiver. The function is passed two arguments, the item and an integer index. If function is nil, then answer the minimum of all items in the receiver.
If the sublist exists in the receiver (in the specified order), at an offset greater than or equal to the initial offset, then return the starting index. The sublist must be of the same kind (class) as the list to search in. Elements are checked for equality (not for identity).
Similar to -find but returns an array of all the indices at which the sequence is found.
Returns the closest index of the value in the collection (collection must be sorted).
Returns a linearly interpolated float index for the value (collection must be sorted). Inverse operation is -blendAt.
Returns a linearly interpolated value between the two closest indices. Inverse operation is -indexInBetween.
Return a new SequenceableCollection which is a copy of the indexed slots of the receiver from start to end. If end < start, an empty collection is returned.
x.copyRange(a, b)
is not equivalent to x[a..b]
. The latter compiles to ArrayedCollection: -copySeries, which has different behavior when end < start.Return a new SequenceableCollection which is a copy of the indexed slots of the receiver from start to the end of the collection. x.copyToEnd(a)
can also be written as x[a..]
Return a new SequenceableCollection which is a copy of the indexed slots of the receiver from the start of the collection to end. x.copyFromStart(a)
can also be written as x[..a]
Remove item from collection. Elements are checked for identity (not for equality).
Remove and return item from collection. The last item in the collection will move to occupy the vacated slot (and the collection size decreases by one). See also takeAt, defined for ArrayedCollection: -takeAt. Elements are checked for identity (not for equality).
take(item)
works on Arrays but not on Lists, because the internally called method takeAt(item)
is not defined for Lists.
Retrieve an element from a given index (like SequenceableCollection: -at). This method is also implemented in Object, so that you can use it in situations where you don't want to know if the receiver is a collection or not. See also: SequenceableCollection: -instill
index |
The index at which to look for an element |
default |
If index exceeds collection size, or receiver is nil, return this instead |
Put an element at a given index (like SequenceableCollection: -put). This method is also implemented in Object, so that you can use it in situations where you don't want to know if the receiver is a collection or not. It will always return a new collection. See also: SequenceableCollection: -obtain
index |
The index at which to put the item |
item |
The object to put into the new collection |
default |
If the index exceeds the current collection's size, extend the collection with this element |
Keep the first n items of the array. If n is negative, keep the last -n items.
Drop the first n items of the array. If n is negative, drop the last -n items.
Returns a String formed by connecting all the elements of the receiver, with joiner inbetween. See also String: -split as the complementary operation.
Returns a collection from which all nesting has been flattened.
Returns a collection from which numLevels of nesting has been flattened.
numLevels |
Specifies how many levels downward (inward) to flatten. Zero returns the original. |
A symmetric version of -flatten. For a negative numLevels
, it flattens starting from the innermost arrays.
numLevels |
Specifies how many levels downward (inward) or upward (outward) to flatten. |
Flatten all subarrays deeper than level.
level |
Specifies from what level onward to flatten. level 0 is outermost, so flatBelow(0) is like flat. |
Invert rows and columns in a two dimensional Collection (turn inside out). See also: Function.
Note that the innermost arrays are not copied:
Flop with a user defined function. Can be used to collect over several collections in parallel.
func |
A function taking as many arguments as elements in the array. |
Invert rows and columns in a an array of dimensional Collections (turn inside out), so that they all match up in size, but remain separated.
Fold dimensions in a multi-dimensional Collection (turn inside out).
rank |
The depth (dimension) from which the array is inverted inside-out. NOTE: Note that, just like in flop, the innermost arrays (deeper than rank) are not copied.
|
Returns the maximum size of all subarrays at a certain depth (dimension)
rank |
The depth at which the size of the arrays is measured |
Returns the maximum depth of all subarrays.
max |
Internally used only. |
Returns true if the collection is an arithmetic series.
step |
Step size to look for. If none is given, any step size will match. |
Returns a new Collection of the desired length, with values resampled evenly-spaced from the receiver without interpolation.
Returns a new Collection of the desired length, with values resampled evenly-spaced from the receiver with linear interpolation.
Choose an element from the collection at random.
Choose an element from the collection at random using a list of probabilities or weights. The weights must sum to 1.0.
Sort the contents of the collection using the comparison function argument. The function should take two elements as arguments and return true if the first argument should be sorted before the second argument. If the function is nil, the following default function is used. { arg a, b; a < b }
Sort the contents of the collection using the key key, which is assumed to be found inside each element of the receiver.
Return an array of indices that would sort the collection into order. function is treated the same way as for the -sort method.
Swap two elements in the collection at indices i and j.
Calls function for each subsequent pair of elements in the SequentialCollection. The function is passed the two elements and an index.
Calls function for every adjacent pair of elements in the SequenceableCollection. The function is passed the two adjacent elements and an index.
Separates the collection into sub-collections by calling the function for each adjacent pair of elements. If the function returns true, then a separation is made between the elements.
Separates the collection into sub-collections by separating every groupSize elements.
Separates the collection into sub-collections by separating elements into groupings whose size is given by integers in the groupSizeList.
Separates the collection into sub-collections by randomly separating elements according to the given probability.
Returns a collection with the incremental sums of all elements.
Returns a collection with the pairwise difference between all elements.
Applies the method named by operator to the first and second elements of the collection, and then applies the method to the result and to the third element of the collection, then applies the method to the result and to the fourth element of the collection, and so on, until the end of the array.
If the collection contains only one element, it is returned as the result. If the collection is empty, returns nil
.
operator |
May be a Function (taking two or three arguments) or a Symbol (method selector). |
adverb |
An optional adverb to be used together with the operator (see Adverbs for Binary Operators). If the operator is a functions, the adverb is passed as a third argument. |
Returns an integer resulting from interpreting the elements as digits to a given base (default 10). See also asDigits in Integer: -asDigits for the complementary method.
Returns the count of array elements that are not equal in identical positions. http://en.wikipedia.org/wiki/Hamming_distance
The collections are not wrapped - if one array is shorter than the other, the difference in size should be included in the count.
With fuzzy comparisons, the arrays do not need to match exactly. We can check how similar they are, and make decisions based on that. This is the magic behind autocorrection.
Returns the minimum number of changes to modify this SequenceableCollection
into the other SequenceableCollection
. A change can be: an addition, a deletion, or a substitution. This is known as the Levenshtein Distance and is implemented in SuperCollider using the Wagner–Fischer algorithm.
The default comparison uses identity - see Object: -== and Object: -===
Where both arrays are raw arrays (String, Int16Array, Int32Array, FloatArray etc., or any derived classes), like comparing two strings, a faster primitive will be used to calculate the distance.
In cases where the arrays are of different types, it will fall back to a slower, non-primitive implementation.
For cases that require comparisons other than identity, the optional compareFunc
can be given to compare elements. This function will be passed two arguments, representing a single element from each array to compare, and this function must return a boolean as to whether or not the elements are equal.
compareFunc
will bypass the primitive and may take significantly longer to execute for larger arrays.other |
The |
compareFunc |
An optional comparison function to use for each element. It will be provided two arguments, and the function must return a boolean as to whether or not they are the same. Default value is |
Returns a value between 0 and 1 representing the percentage similarity between this SequenceableCollection
and the other SequenceableCollection
.
A value of 1 means they are exactly the same, a value of 0 means they are completely different. This is calculated based on the -editDistance
other |
The |
compareFunc |
An optional compareFunc to be used to calculate the edit distance (see -editDistance) |
All of the following messages send the message -performUnaryOp to the receiver with the unary message selector as an argument.
Creates a new collection of the results of applying the selector to all elements in the receiver.
All of the following messages send the message -performBinaryOp to the receiver with the binary message selector and the second operand as arguments.
Creates a new collection of the results of applying the selector with the operand to all elements in the receiver. If the operand is a collection then elements of that collection are paired with elements of the receiver.
A variety of Special Functions are supplied by the Boost C++ library. The library's online documentation serves as the primary reference for the following functions. The methods here match closely with those found in the source library, as do argument names.
Below you'll find descriptions of the functions and their bounds, but for visualizing the functions, have a look in Tour of Special Functions.
.
), but should be read to suggests the usage: foo([a], [b])
. The equivalent receiver notation is: [a].foo([b])
. Note that those methods with only one argument erroneously omit that argument from the argument list; each element in the collection is implicitly passed as the method's argument, e.g. foo([a])
or [a].foo
Returns the (2*n
)th Bernoulli number.
Because all odd numbered Bernoulli numbers are zero (apart from B(1) which is -1/2) the interface will only return the even numbered Bernoulli numbers.
Returns a single tangent number at i
. Also called a zag function.
Returns the "true gamma" of value z
.
Returns gamma(dz + 1) - 1
.
Returns the natural logarithm of the gamma function.
Returns the digamma or psi function of z
.
Digamma is defined as the logarithmic derivative of the gamma function.
Returns the trigamma function of z
.
Trigamma is defined as the derivative of the digamma function.
Returns the polygamma function of z
.
Polygamma is defined as the n
'th derivative of the digamma function.
Returns the ratio of gamma functions tgamma(a) / tgamma(b)
.
Returns the ratio of gamma functions tgamma(a) / tgamma(a+delta)
.
Returns the normalised lower incomplete gamma function.
Requires a
> 0 and z
>= 0.
Returns the normalised upper incomplete gamma function.
Requires a
> 0 and z
>= 0.
Returns the full (non-normalised) lower incomplete gamma function.
Requires a
> 0 and z
>= 0.
Returns the full (non-normalised) upper incomplete gamma function.
Requires a
> 0 and z
>= 0.
Returns a value such that p = gamma_p(a, x)
.
Requires a
> 0 and 1 >= p,q
>= 0.
Returns a value x such that q = gamma_q(a, x)
.
Requires a
> 0 and 1 >= p,q
>= 0.
Returns a value such that p = gamma_p(a, x)
.
Requires x
> 0 and 1 >= p,q
>= 0.
Returns a value x such that q = gamma_q(a, x)
.
Requires x
> 0 and 1 >= p,q
>= 0.
Implements the partial derivative with respect to x of the incomplete gamma function (lower).
Implements the partial derivative with respect to x of the incomplete gamma function (upper).
Returns i!
.
factorial
will overflow if i > 170
Returns i!!
.
For even i
, i !! = i(i-2)(i-4)(i-6) ... (4)(2)
.
For odd i
, i !! = i(i-2)(i-4)(i-6) ... (3)(1)
.
Returns the rising factorial of x
and i
:
x(x+1)(x+2)(x+3)...(x+i-1)
Both x
and i
can be negative as well as positive.
Returns the falling factorial of x
and i
:
x(x-1)(x-2)(x-3)...(x-i+1)
This function is only defined for positive i
. Argument x
can be either positive or negative.
Requires k
<= n
.
The beta function is defined by: tgamma(a)*tgamma(b) / tgamma(a+b)
.
Returns the normalised incomplete beta function of a
, b
and x
.
Require 0 <= x
<= 1, a,b
>= 0, and in addition that not both a
and b
are zero.
Returns the normalised complement of the incomplete beta function of a
, b
and x
.
Require 0 <= x
<= 1, a,b
>= 0, and in addition that not both a
and b
are zero.
Returns the full (non-normalised) incomplete beta function of a
, b
and x
.
Require 0 <= x
<= 1, and a,b
> 0.
Returns the full (non-normalised) complement of the incomplete beta function of a
, b
and x
.
Require 0 <= x
<= 1, and a,b
> 0.
Returns a value x
such that: p = ibeta(a, b, x)
.
Requires a,b
> 0 and 0 <= p
<= 1.
Returns a value x
such that: q = ibetaC(a, b, x)
.
Requires a,b
> 0 and 0 <= q
<= 1.
Returns a value a
such that: p = ibeta(a, b, x)
.
Requires b
> 0, 0 < x
< 1, and 0 <= p
<= 1.
Returns a value a
such that: q = ibetaC(a, b, x)
.
Requires b
> 0, 0 < x
< 1, and 0 <= q
<= 1.
Returns a value b
such that: p = ibeta(a, b, x)
.
Requires a
> 0, 0 < x
< 1, and 0 <= p
<= 1.
Returns a value b
such that: q = ibetaC(a, b, x)
.
Requires a
> 0, 0 < x
< 1, and 0 <= q
<= 1.
Returns the partial derivative with respect to x
of the incomplete beta function ibeta(a,b,x)
.
Returns the error function of z
.
Returns the complement of the error function of z
.
Returns the inverse error function of z
, that is a value x
such that:
p = erf(x)
.
Returns the inverse of the complement of the error function of z
, that is a value x
such that:
p = erfC(x)
Returns the Legendre Polynomial of the first kind.
Requires -1 <= x
<= 1.
Returns the derivatives of the Legendre polynomials.
Since the Legendre polynomials are alternatively even and odd, only the non-negative zeros are returned. For the odd Legendre polynomials, the first zero is always zero. The rest of the zeros are returned in increasing order.
Returns the associated Legendre polynomial of the first kind.
Requires -1 <= x
<= 1.
Returns the value of the Legendre polynomial that is the second solution to the Legendre differential equation.
Requires -1 <= x
<= 1.
Returns the value of the Laguerre Polynomial of order n
at point x
.
Returns the Associated Laguerre polynomial of degree of dgree n
and order m
at point x
.
Returns the value of the Hermite Polynomial of order n
at point x
.
Returns the Chebyshev polynomials of the first kind.
Returns the Chebyshev polynomials of the second kind.
Returns the derivatives of the Chebyshev polynomials of the first kind.
Returns the roots (zeros) of the n
-th Chebyshev polynomial of the first kind.
Returns the (Complex
) value of the Spherical Harmonic.
theta
is taken as the polar (colatitudinal) coordinate within [0, pi]
, and phi
as the azimuthal (longitudinal) coordinate within [0,2pi]
.
See boost documentation for further information, including a note about the Condon-Shortley phase term of (-1)^m
.
Returns the real part of the Spherical Harmonic.
Returns the imaginary part of the Spherical Harmonic.
Returns the result of the Bessel functions of the first kind.
The functions return the result of domain_error
whenever the result is undefined or complex. This occurs when x < 0
and v
is not an integer, or when x == 0
and v != 0
.
Returns the result of the Bessel functions of the second kind.
The functions return the result of domain_error
whenever the result is undefined or complex. This occurs when x <= 0
.
Returns a single zero or root of the Bessel function of the first kind.
index
is a 1-based index of zero of the cylindrical Bessel function of order v
.
Returns a single zero or root of the Neumann function (Bessel function of the second kind).
index
is a 1-based index of zero of the cylindrical Neumann function of order v
.
Returns the result of the modified Bessel functions of the first kind.
Returns the result of the modified Bessel functions of the second kind.
Requires x > 0
.
Returns the result of the spherical Bessel functions of the first kind.
Requires x
> 0.
Returns the result of the spherical Bessel functions of the first kind.
Requires x
> 0.
Returns the first derivative with respect to x of the corresponding Bessel function.
Returns the first derivative with respect to x of the corresponding Neumann function.
Requires x > 0
.
Returns the first derivative with respect to x of the corresponding Bessel function.
Returns the first derivative with respect to x of the corresponding Bessel function.
Requires x > 0
.
Returns the first derivative with respect to x of the corresponding Bessel function.
Requires x > 0
.
Returns the first derivative with respect to x of the corresponding Neumann function.
Requires x > 0
.
Returns the result of the Hankel functions of the first kind.
Returns the result of the Hankel functions of the second kind.
Returns the result of the spherical Hankel functions of the first kind.
Returns the result of the spherical Hankel functions of the second kind.
Returns the result of the Airy function Ai at x
.
Returns the result of the Airy function Bi at x
.
Returns the derivative of the Airy function Ai at x
.
Returns the derivative of the Airy function Bi at x
.
Returns the m
th zero or root of the Airy Ai function. The Airy Ai function has an infinite number of zeros on the negative real axis.
m
is 1-based.
Returns the m
th zero or root (1-based) of the Airy Bi function. The Airy Bi function has an infinite number of zeros on the negative real axis.
m
is 1-based.
Returns Carlson's Elliptic Integral RF.
Requires that x,y >= 0
, with at most one of them zero, and that z >= 0
.
Returns Carlson's Elliptic Integral RD.
Requires that x,y >= 0
, with at most one of them zero, and that z >= 0
.
Returns Carlson's Elliptic Integral RJ.
Requires that x,y,z >= 0
, with at most one of them zero, and that p != 0
.
Returns Carlson's Elliptic Integral RC.
Requires that x >= 0
, with at most one of them zero, and that y != 0
.
Returns Carlson's Elliptic Integral RG.
Requires that x,y >= 0
.
Returns the incomplete elliptic integral of the first kind, Legendre form.
Requires -1 <= k <= 1
.
Returns the complete elliptic integral of the first kind, Legendre form.
Requires -1 <= k <= 1
.
Returns the incomplete elliptic integral of the second kind, Legendre form.
Requires -1 <= k <= 1
.
Returns the complete elliptic integral of the second kind, Legendre form.
Requires -1 <= k <= 1
.
Returns the incomplete elliptic integral of the third kind, Legendre form.
Requires -1 <= k <= 1
and n < 1/sin^2(phi)
.
Returns the complete elliptic integral of the third kind, Legendre form.
Requires -1 <= k <= 1
and n < 1
.
Returns the incomplete elliptic integral D(phi, k), Legendre form.
Requires -1 <= k <= 1
.
Returns the complete elliptic integral D(phi, k), Legendre form.
Requires -1 <= k <= 1
.
Returns the result of the Jacobi Zeta Function.
Requires -1 <= k <= 1
.
Returns the result of the Heuman Lambda Function.
Requires -1 <= k <= 1
.
Returns the zeta function of z
.
Requires z != 1
.
Returns the exponential integral En of z
.
Requires that when n == 1
, z !=0
.
Returns the exponential integral of z
.
Requires z != 0
.
Returns sin(x * π)
.
Returns cos(x * π)
.
Returns the natural logarithm of x+1
.
Returns e^x - 1
.
Returns the cube root of x
.
Returns sqrt(1+x) - 1
.
Returns x^y - 1
.
Returns the Sinus Cardinal of x
. Also known as the "sinc" function.
sincPi(x) = sin(x) / x
Returns the Hyperbolic Sinus Cardinal of x
.
sinhcPi(x) = sinh(x) / x
Returns the reciprocal of the hyperbolic sine function at x
.
Returns the reciprocal of the hyperbolic cosine function at x
.
Requires x >= 1
.
Returns the reciprocal of the hyperbolic sine function at x
.
Requires -1 < x < 1
.
Returns the Owens T function of h
and a
.
All of the following messages are performed on the elements of this collection, using Object: -multiChannelPerform.
The result depends on the objects in the collection, but the main use case is for UGens.
See also Multichannel Expansion
Calls this.multiChannelPerform(selector, *args)
where selector is the name of the message.
This method is called internally on inputs to UGens that take multidimensional arrays, like Klank and it allows proper multichannel expansion even in those cases. For SequenceableCollection, this returns the collection itself, assuming that it contains already a number of Refs. See Ref for the corresponding method implementation.
rank |
The depth at which the list is expanded. For instance the Klank spec has a rank of 2. For more examples, see SequenceableCollection: -flopDeep |
Convert a rhythm-list to durations.
supports a variation of Mikael Laurson's rhythm list RTM-notation.1
The method converts a collection of the form [beat-count, [rtm-list], repeats]
to a List of Floats. A negative integer within the rtm-list equates to a value tied over to the duration following. The method is recursive in that any subdivision within the rtm-list can itself be a nested convertRhythm collection (see example below). The repeats integer has a default value of 1.
If the divisions in the rtm-list are events, the event durations are interpreted as relative durations, and a list of events is returned.
Execute a UNIX command asynchronously. This object should be an array of strings where the first string is the path to the executable to be run and all other strings are passed as arguments to the executable. This method starts the process directly without using a shell.
action |
A Function that is called when the process has exited. It is passed two arguments: the exit code and pid of the exited process. |
postOutput |
A Boolean that controls whether or not the output of the process is displayed in the post window. |
An Integer - the pid of the newly created process. Use Integer: -pidRunning to test if a process is alive.
Example:
Similar to -unixCmd except that the stdout of the process is returned (synchronously) rather than sent to the post window. This object should be an array of strings where the first string is the path to the executable to be run and all other strings are passed as arguments to the executable. This method starts the process directly without using a shell.
When receiving arrays in an OSC message that have been converted with -asOSCArgArray, according to the OSC standard using $[ and $] characters, this converts them back.
Prepare a nested array for sending via OSC
Unpack a nested array for sending via OSC