Arrays are ArrayedCollections whose slots may contain any object. Arrays have a fixed maximum size beyond which they cannot grow. For expandable arrays, use the List class.
Literal Arrays can be created at compile time, and are very efficient. See Literals for information.
For handling multidimensional arrays, there are specific methods which are covered in the helpfile J concepts in SC.
add method may or may not return the same Array object. It will add the argument to the receiver if there is space, otherwise it returns a new Array object with the argument added. Thus the proper usage of add with an Array is to always assign the result as follows:This allows an efficient use of resources, only growing the array when it needs to. The List class manages the Array internally, and in many cases is more suitable.
Items can be put into an existing slot with a.put(2, obj) and accessed with a.at(2) or a[2].
a.put(2, obj), a.at(2), and a[2] refers to the third item.See ArrayedCollection for the principal methods: at, put, clipAt, wrapAt, etc.
Create a new array with size 0 that can grow up to the fixed size.
| maxSize |
The maximum size of the array. |
Create a new array with all slots filled with nils.
| indexedSize |
The size of the array. |
Create a new Array whose slots are filled with the given arguments. This is the same as the method in ArrayedCollection, but is reimplemented here to be more efficient.
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". |
Creates a 2 dimensional Collection of the given sizes. The items are determined by evaluation of the supplied function. The function is passed row and column indexes as arguments. See J concepts in SC
Creates a N dimensional Collection where N is the size of the array dimensions. The items are determined by evaluation of the supplied function. The function is passed N number of indexes as arguments. See J concepts in SC
Creates a new Collection from another collection. This supports the interface for the method "as".
Fill an ArrayedCollection with a geometric series.
Fill an ArrayedCollection with an arithmetic series.
Fills an ArrayedCollection with a counter. See J concepts in SC for more examples.
Fill a SequenceableCollection with the interpolated values between the start and end values.
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 a fibonacci series.
| size |
the number of values in the collection |
| a |
the starting step value |
| b |
the starting value |
Fill an array with radian values representing the vertices of a regular convex polygon.
| size |
The number of vertices. | ||||||||
| orientation |
A value in radians specifying the first vertex. Or, by keyword:
| ||||||||
| wrap |
Angle wrap, in radians. |
Create a new array with all slots filled with 0.0.
Returns the item at index, specified as an integer (or float) starting from 0.
The index can also be an Array of indices to extract specified elements:
Float indices are also supported with the following behavior:
this.at(0).<= -1 or >= this.size, return nil.A sound example:
Put item at index starting from 0, replacing what is there. index can be an array of indices. If a float is used as index, it will be truncated.
Example:
Inserts the item into the contents of the receiver at the specified index, which is an integer starting from 0. This method may return a new ArrayedCollection. For this reason, you should always assign the result of insert to a variable - never depend on add changing the receiver.
Changes the receiver but maintains its size, therefore unlike .insert it is not necessary to reassign the result of .boundedInsert.
Similar to -at, but guarantees that any value for index is valid by clipping values outside the collection's bounds. Values greater than size - 1 are clipped to that last index, and values below 0 (negative) are clipped to 0. The index can also be an array of indices to extract the specified elements. SequenceableCollection: -|@| is its syntactic shortcut.
Similar to -at, but guarantees that any value for index is valid by wrapping values outside the collection's bounds. If the index exceeds size - 1, it wraps back around to 0. Similarly, if the index is below 0 (negative), it wraps to access elements from the end of the collection. this.wrapAt(index) is equivalent to this.at(index mod: size), ensuring the index is always within the valid range of the collection. The index can also be an array of indices to extract the specified elements. SequenceableCollection: -@@ is its syntactic shortcut.
Similar to -at, but guarantees that any value for index is valid by reflecting values outside the collection's bounds. Values greater than size - 1 are reflected back toward lower indices. Similarly, if the index is below 0 (negative), it folds in the opposite direction. This creates a symmetrical mapping of any index within the collection's boundaries. The index can also be an array of indices to extract the specified elements. SequenceableCollection: -@|@ is its syntactic shortcut.
Same as -put, but values for index greater than the ArrayedCollection instance size minus one will be clipped to size - 1, which is the last index.
Same as -put, but values for index greater than the ArrayedCollection instance size minus one will be wrapped around to 0.
Same as -put, but values for index greater than the ArrayedCollection instance size minus one will be folded back.
Swap the values at indices i and j, both specified as integers starting from 0.
Return a new array in which a number of elements have been replaced by another. Elements are checked for equality (not for identity).
this method is inherited by String :
Concatenate the contents of the two collections into a new ArrayedCollection.
Adds an item to an ArrayedCollection if there is space. This method may return a new ArrayedCollection. For this reason, you should always assign the result of add to a variable - never depend on add changing the receiver.
Adds all the elements of aCollection to the contents of the receiver. This method may return a new ArrayedCollection. For this reason, you should always assign the result of addAll to a variable - never depend on add changing the receiver.
Inserts the item before the contents of the receiver, possibly returning a new collection.
Remove and return the item at index, specified as an integer or a float starting from 0, shrinking the size of the ArrayedCollection.
Answer a new collection which consists of the results of function evaluated for each item in the collection. The function is passed two arguments, the item and an integer index. See Collection helpfile for examples.
Iterate over the elements in order, calling the function for each element. The function is passed two arguments, the element and an index.
Iterate over the elements in reverse order, calling the function for each element. The function is passed two arguments, the element and an index.
The same as -collect, but can look inside sub-arrays up to the specified depth.
For a multidimensional array, rearranges the data using the desired number of elements along each dimension. The data may be extended using Array: -wrapExtend if needed. This will always return a rectangular array, see -isRectangular.
Interprets the array as a list of probabilities which should sum to 1.0 and returns a random index value based on those probabilities. The random index is taken from the receiver's index, starting from 0.
Return the number of elements the ArrayedCollection.
Returns a new Array with the receiver items normalized between min and max.
Returns the Array resulting from :
so that the array will sum to 1.0.
This is useful for using with windex or wchoose.
Plot values in a GUI window. See plot for more details. When the receiver contains nil items, the plot fails with an error.
Returns a new Array whose elements are reversed. The receiver is unchanged.
Returns a new Array whose elements have been scrambled. The receiver is unchanged.
Return a new Array which is the receiver made into a palindrome. The receiver is unchanged.
Return a new Array which is the receiver made into a palindrome with the last element removed. This is useful if the list will be repeated cyclically, the first element will not get played twice. The receiver is unchanged. If the receiver is a single-element array, a copy is returned.
Return a new Array which is the receiver concatenated with a reversal of itself. The center element is duplicated. The receiver is unchanged.
dupEach instead. This method is retained for backwards compatibility.Return a new Array whose elements are repeated n times. The receiver is unchanged.
| n |
Number of repeats. |
Return a new Array whose elements are repeated n times. The receiver is unchanged.
| n |
Number of repeats. |
Return a new Array whose elements are in rotated order. The receiver is unchanged.
| n |
Number of elements to rotate. Negative n values rotate left, positive n values rotate right. |
Return a new Array whose elements have been reordered via one of 10 "counting" algorithms. Run the examples to see the algorithms.
| patternType |
Choose counting algorithm. The algorithms are numbered 1 through 10. |
Like pyramid, but keep the resulting values grouped in subarrays.
Return a new Array of length maxlen with the items partly repeated (random choice of given probability).
| probability |
Probability of repeat. |
| maxlen |
The length of the new Array. |
Returns a new Array whose elements are interlaced sequences of the elements of the receiver's subcollections, up to size length. The receiver is unchanged.
Returns a new Array whose elements are the nthPermutation of the elements of the receiver. The receiver is unchanged.
Returns a new Array whose elements contain all possible combinations of the receiver's subcollections.
Returns a new Array whose elements are repeated sequences of the receiver, up to size length. The receiver is unchanged.
Same as wrapExtend but the sequences fold back on the list elements.
Same as wrapExtend but the sequences "clip" (return their last element) rather than wrapping.
Return a new Array whose elements are repeated subsequences from the receiver. Easier to demonstrate than explain.
Shift the values of the array n steps to the right (n positive) or to the left(n negative), dropping the excess and filling empty space with zero.
Returns true if the receiver Array contains any instance of SequenceableCollection
Returns all possible combinations of the array's elements.
powerset is also supported in Collection:
Given an array of symbols, this returns an array of pairs of (symbol, value) from the current environment. This can then be used as arguments for a Synth, or in an OSC message.
Invert rows and columns in a two dimensional Array (turn inside out). See also: Function, SequenceableCollection.
Used by UGens to perform multi channel expansion. Same as flop.
Some UGens return Arrays of OutputProxy when instantiated. This method allows you to get at the source UGen.
Used within Routines and assumes an array of functions, from which subroutines are created. The subroutines are played while the outer Routine carries on. The join parameter expresses after how many subroutines complete the outer Routine is allowed to go on. By default this happens after all subroutines have completed.
apply an array of Poll units to an array of UGens (see those helpfiles for more details).
apply an array of Dpoll units to an array of UGens (see those helpfiles for more details).
This method is used by IdentitySet to search for a key among its members.
This method is used by IdentityDictionary to search for a key among its members.
Returns a string representing the Array. May not be compilable due to elision (...) of excessive arguments.
Returns a string that will compile to return an Array equal to the receiver.
Returns true. Arrays are valid UGen inputs.
Returns the OSC message as an Int8Array. Receiver can be a message or a bundle. See also Int8Array: -parseOSC.
Send this Array's content to Bela's Oscilloscope (see BelaScope for required setup)
| scopeChannel |
Bela's oscilloscope channel to start scoping on. This has to be a non-negative number, and can't be changed after scoping starts. |
| server |
The server on which BelaScope is running. If not specified, it looks for the first server for which BelaScope was already initialized. If none is found, it attempts to initialize a BelaScope instance on Server: *default. |
This Array.
Browse Math/Cycle
Cycle includes the methods Array: -campanology, Array: -circPerm, Array: -interlace, Array: -kaprekar, Array: -kreuzspiel, Array: -pea, Array: -sieve, Array: -symGroup, Array: -symPerm, Integer: -campanology,Integer: -circPerm, Integer: -collatz, Integer: -discreteLog, Integer: -euclidean, Integer: -kaprekar, Integer: -pea, Number: -lorenz, Env: *collatz.
As a musical study of bells, campanology focuses on the ringing methods according to the two following rules:
The algorithm provides a trivial solution – called the 'hunting group' – by permuting consecutive pairs and alternating the starting position between the first and the second position.
Reference: White, A., & Wilson, R. (1995). The Hunting Group. The Mathematical Gazette, 79(484), 5–16. https://doi.org/10.2307/3619985
| mode |
assigns the first switched couple as indices either 0 or 1. |
| rev |
Boolean, stops the algorithm when its input is reversed. |
| sym |
Boolean, 'escape from hunt' as a palindromic process for odd number of bells. |
the cycle itself.
This algorithm consists of moving the first element of a list to the tail of this list. This is done n times with n equal to the length of the list according to a circular permutation cycle from a given radix to another.
| iBase |
initial base |
| cBase |
circular base |
the cycle as a circular permutation according to the radix as arguments.
Based on the principle of ornamental interlace, each array as a 'pattern' is repeated some times according to the least common multiple to generate a complete cycle.
an array where each element groups the circular permutations of each array as a 'pattern' such as the number of voices equal to the number of arrays.
Apply the method Integer: -kaprekar to an array according to a given radix (10 by default).
| base |
an array with the cycle itself prepended by its 'path' if it exists.
In 1951, Karlheinz Stockhausen wrotes Kreuzspiel (« Jeux croisés ») which uses the crossing technique inspired by Olivier Messiaen called « des extrêmes au centre » as a kind of retrogradation « en éventail ». This consists to take the first and the last values of a sequence and places them in the middle (or optionally at a given indexed place) by opposite crossing.
Reference at http://hdl.handle.net/1773/23571
| ind |
as indice, |
The cycle itself.
Primarily developed by John Conway, the pea pattern is a variation of a 'look-and-say' sequence by counting the elements of a seed from the lowest number to the highest iteratively until the effectiveness of a cycle.
The cycle itself prepended by its 'path' if it exists.
Kind of Metabole according to Iannis Xenakis, rhythmic sieves rely on the construction of a matrix to generate two cycles: one by horizontal shift and one by vertical shift.
For instance, with i = 4 and j = 5, the shifting cycle is done according to the following matrix:
| 0 | 1 | 2 | 3 | |
| 0 | 0 | 5 | 10 | 15 |
| 1 | 16 | 1 | 6 | 11 |
| 2 | 12 | 17 | 2 | 7 |
| 3 | 8 | 13 | 18 | 3 |
| 4 | 4 | 9 | 14 | 19 |
i should be strictly inferior to j. Also, this kind of matrix requires i.gcd(j) == 1.| field |
set the maximum value of the matrix, | |||||||||
| i |
as the x-axis of the matrix. | |||||||||
| j |
as the y-axis of the matrix. | |||||||||
| optimize |
requires one of the following symbols:
|
an array of two cycles.
The symmetric group allows to enumerate all cycles from a list of n elements according to their respective position of the same ordered list (i.e. { 1, 2, ..., n }) such as each set is a group of permutations as a bijective maps.
a list of cycles.
Highlighted by Olivier Messiaen, symmetric permutations constitute a system of numbered durations that consists in changing the order of its durations in order to obtain a limited number of rhythmic cells.
| arrayCode |
allows to re-order durations |
the cycle as a symmetric permutation according to an re-ordered array as arguments.
Obtains all the relative maxima in an array of [freqs, mags] pairs such as that returned from FFT data. It operates on the magnitudes finding all the inflection points.
[[freqs],[mags]]
Returns the n highest partials of a [freqs, mags] array such as returned from the maxima method. See Live Dissonance.
The collectAccum function behaves like a combination of collect and inject; it applies a function to each element of an array, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new array.
| init |
Initial state s |
| f |
A function with first argument the previous value of the state, second argument the value from the array. It should return a Tuple2 with the new value of the state and a new value for the final array. s -> b -> (s, c) |
T( s, [ c ] )
scanl is similar to inject, but returns a list of successive reduced values.
| init |
initial value s |
| f |
function to combine the current state with the element of the array s -> a -> s |
[s]
Fold a list using the monoidal zero and the monoidal binary operation
convert to LazyList
if the index is valid return Some(element) if not return None()
| i |
index |
Transform an array of options into an array of values by dropping the None() values.
Transform an array of options into an array of values by dropping the None() values. If the array is empty returns None() otherwise returns Some( xs ) .
traverse an array with effects using applicative functors. see the haskell documentation