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.
Elements can be put into an existing slot with a.put(2,obj)
and accessed with a.at(2)
or a[2]
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 |
Create a new array with all slots filled with 0.0.
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. |
Return the item at index.
The index can also be an Array of indices to extract specified elements. Example:
Put item at index, replacing what is there.
Inserts the item into the contents of the receiver. 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.
Same as -at, but values for index greater than the size of the ArrayedCollection will be clipped to the last index.
Same as -at, but values for index greater than the size of the ArrayedCollection will be wrapped around to 0.
Same as -at, but values for index greater than the size of the ArrayedCollection will be folded back.
Same as -put, but values for index greater than the size of the ArrayedCollection will be clipped to the last index.
Same as -put, but values for index greater than the size of the ArrayedCollection will be wrapped around to 0.
Same as -put, but values for index greater than the size of the ArrayedCollection will be folded back.
Swap the values at indices i and j.
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 element at index, 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 wrapExtend if needed.
Interprets the array as a list of probabilities which should sum to 1.0 and returns a random index value based on those probabilities.
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 must be a bundle.
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.