/usr/share/SuperCollider/HelpSource/Classes/Array.schelp is in supercollider-common 1:3.8.0~repack-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | class:: Array
summary:: fixed size collection
related:: Reference/Literals, Classes/List
categories:: Collections>Ordered
description::
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 link::Classes/List:: class.
strong::Literal Arrays:: can be created at compile time, and are very efficient. See link::Reference/Literals:: for information.
For handling strong::multidimensional arrays::, there are specific methods which are covered in the helpfile link::Guides/J-concepts-in-SC::.
note::
For Arrays, the code::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 code::add:: with an Array is to always assign the result as follows:
code::
z = z.add(obj);
::
This allows an efficient use of resources, only growing the array when it needs to. The link::Classes/List:: class manages the Array internally, and in many cases is more suitable.
::
Elements can be put into an existing slot with code::a.put(2,obj):: and accessed with
code::a.at(2):: or code::a[2]::
See link::Classes/ArrayedCollection:: for the principal methods: at, put, clipAt, wrapAt, etc...
ClassMethods::
method::new
Create a new array with size 0 that can grow up to the fixed size.
argument::maxSize
The maximum size of the array.
method::newClear
Create a new array with all slots filled with nils.
argument::indexedSize
The size of the array.
method::with
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.
code::
Array.with(7, 'eight', 9).postln;
::
copymethod:: Collection *fill
copymethod:: Collection *fill2D
copymethod:: Collection *fillND
copymethod:: Collection *newFrom
copymethod:: ArrayedCollection *geom
copymethod:: ArrayedCollection *series
copymethod:: ArrayedCollection *iota
copymethod:: Collection *interpolation
copymethod:: Collection *rand
copymethod:: Collection *rand2
copymethod:: Collection *linrand
copymethod:: Collection *exprand
copymethod:: Collection *fib
InstanceMethods::
copymethod:: ArrayedCollection -at
copymethod:: ArrayedCollection -put
copymethod:: ArrayedCollection -insert
copymethod:: ArrayedCollection -overWrite
copymethod:: ArrayedCollection -clipAt
copymethod:: ArrayedCollection -wrapAt
copymethod:: ArrayedCollection -foldAt
copymethod:: ArrayedCollection -slice
copymethod:: ArrayedCollection -clipPut
copymethod:: ArrayedCollection -wrapPut
copymethod:: ArrayedCollection -foldPut
copymethod:: ArrayedCollection -swap
copymethod:: ArrayedCollection -replace
copymethod:: ArrayedCollection -++
copymethod:: ArrayedCollection -add
copymethod:: ArrayedCollection -addAll
copymethod:: ArrayedCollection -addFirst
copymethod:: ArrayedCollection -removeAt
copymethod:: ArrayedCollection -collect
copymethod:: ArrayedCollection -do
copymethod:: ArrayedCollection -reverseDo
copymethod:: ArrayedCollection -deepCollect
copymethod:: ArrayedCollection -reshape
copymethod:: ArrayedCollection -bubble
copymethod:: ArrayedCollection -unbubble
copymethod:: ArrayedCollection -windex
copymethod:: ArrayedCollection -size
copymethod:: ArrayedCollection -normalize
copymethod:: ArrayedCollection -normalizeSum
copymethod:: ArrayedCollection -plot
method::reverse
Returns a new Array whose elements are reversed. The receiver is unchanged.
code::
x = [1, 2, 3];
z = x.reverse;
x.postln;
z.postln;
::
method::scramble
Returns a new Array whose elements have been scrambled. The receiver is unchanged.
code::
[1, 2, 3, 4, 5, 6].scramble.postln;
::
method::mirror
Return a new Array which is the receiver made into a palindrome.
The receiver is unchanged.
code::
[1, 2, 3, 4].mirror.postln;
::
method::mirror1
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.
code::
[1, 2, 3, 4].mirror1.postln;
::
method::mirror2
Return a new Array which is the receiver concatenated with a reversal of itself.
The center element is duplicated. The receiver is unchanged.
code::
[1, 2, 3, 4].mirror2.postln;
::
method::stutter
Return a new Array whose elements are repeated n times. The receiver is unchanged.
code::
[1, 2, 3].stutter(2).postln;
::
argument::n
Number of repeats.
method::rotate
Return a new Array whose elements are in rotated order. The receiver is unchanged.
code::
[1, 2, 3, 4, 5].rotate(1).postln;
[1, 2, 3, 4, 5].rotate(-1).postln;
[1, 2, 3, 4, 5].rotate(3).postln;
::
argument::n
Number of elements to rotate. Negative n values rotate left, positive n values
rotate right.
method::pyramid
Return a new Array whose elements have been reordered via one of 10 "counting" algorithms.
Run the examples to see the algorithms.
code::
10.do({ arg i;
[1, 2, 3, 4].pyramid(i + 1).postcs;
});
::
argument::patternType
Choose counting algorithm. The algorithms are numbered 1 through 10.
method::pyramidg
Like pyramid, but keep the resulting values grouped in subarrays.
code::
// compare:
[1, 2, 3, 4].pyramid(1).postln;
[1, 2, 3, 4].pyramidg(1).postln;
::
method::sputter
Return a new Array of length maxlen with the items partly repeated (random choice of given probability).
code::
// compare:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].sputter(0.5, 16).postln;
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].sputter(0.8, 8).postln;
::
argument::probability
Probability of repeat.
argument::maxlen
The length of the new Array.
method::lace
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.
code::
x = [ [1, 2, 3], 6, List["foo", 'bar']];
y = x.lace(12);
x.postln;
y.postln;
::
method::permute
Returns a new Array whose elements are the nthPermutation of the elements of the receiver. The receiver is unchanged.
code::
x = [ 1, 2, 3];
6.do({|i| x.permute(i).postln;});
::
method::allTuples
Returns a new Array whose elements contain all possible combinations of the receiver's subcollections.
code::
[[1, 2, 3, 4, 5], [10, 20, 30]].allTuples;
[[1, 2, 3, 4, 5], [10, 20, 30], [5, 6]].allTuples;
::
method::wrapExtend
Returns a new Array whose elements are repeated sequences of the receiver, up to size length. The receiver is unchanged.
code::
x = [ 1, 2, 3, "foo", 'bar' ];
y = x.wrapExtend(9);
x.postln;
y.postln;
::
method::foldExtend
Same as wrapExtend but the sequences fold back on the list elements.
code::
x = [ 1, 2, "foo"];
y = x.foldExtend(9);
x.postln;
y.postln;
::
method::clipExtend
Same as wrapExtend but the sequences "clip" (return their last element) rather than wrapping.
code::
x = [ 1, 2, "foo"];
y = x.clipExtend(9);
x.postln;
y.postln;
::
method::slide
Return a new Array whose elements are repeated subsequences from the receiver.
Easier to demonstrate than explain.
code::
[1, 2, 3, 4, 5, 6].slide(3, 1).postcs;
[1, 2, 3, 4, 5, 6].slide(3, 2).postcs;
[1, 2, 3, 4, 5, 6].slide(4, 1).postcs;
::
method::shift
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.
code::
[1, 2, 3, 4, 5, 6].shift(3).postln;
[1, 2, 3, 4, 5, 6].shift(-3).postln;
::
method::containsSeqColl
Returns true if the receiver Array contains any instance of SequenceableCollection
code::
[1, 2, 3, 4].containsSeqColl.postln
[1, 2, [3], 4].containsSeqColl.postln
::
method::powerset
Returns all possible combinations of the array's elements.
code::
[1, 2, 3].powerset.postln
[1, 2, 3].powerset.sort({ |a, b| a.size > b.size }); // sort by size, big first
[1, 2, 3].powerset.sort({ |a, b| a.size > b.size }).reverse; // by size, small first
::
powerset is also supported in Collection:
code::
Set[1, 2, 3].powerset;
List[1, 2, 3].powerset
(a: 1, b: 2, c: 3).powerset;
::
method::envirPairs
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.
code::
e = (freq: 340, amp: 0.001, strangeness: 0.85);
e.use {
[\amp, \taste, \strangeness].envirPairs;
}
::
method::flop
Invert rows and columns in a two dimensional Array (turn inside out).
See also: Function, SequenceableCollection.
code::
[[1, 2, 3], [4, 5, 6]].flop;
[[1, 2, 3], [4, 5, 6], [7, 8]].flop; // shorter array wraps
[].flop; // result is always 2-d.
::
method::multiChannelExpand
Used by UGens to perform multi channel expansion. Same as flop.
method::source
Some UGens return Arrays of OutputProxy when instantiated. This method allows you to
get at the source UGen.
code::
z = Pan2.ar;
z.postln;
z.source.postln;
::
method::fork
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.
code::
// an array of routine functions:
(
a = [
{ 1.wait; \done_one.postln },
{ 0.5.wait; \done_two.postln },
{ 0.2.wait; \done_three.postln }
];
)
// join after 0
(
Routine {
"join = 0.".postcln;
a.fork(0); \doneAll.postln;
}.play;
)
// join after 1
(
Routine {
"join = 1.".postcln;
a.fork(1); \doneAll.postln;
}.play;
)
// join after all
(
Routine {
"join = a.size (default).".postcln;
a.fork; \doneAll.postln;
}.play;
)
poll(trig, label, trigid)
apply an array of Poll units to an array of UGens (see those helpfiles for more details).
s.boot;
(
x = {
SinOsc.ar([0.1, 0.2], 0).poll * 0.1
}.play;
)
x.trace; // By tracing the Synth you can see the two Poll units we created
x.free
::
method::dpoll
apply an array of Dpoll units to an array of UGens (see those helpfiles for more details).
method::atIdentityHash
This method is used by IdentitySet to search for a key among its members.
method::atIdentityHashInPairs
This method is used by IdentityDictionary to search for a key among its members.
method::asString
Returns a string representing the Array. May not be compilable due to elision (...) of excessive arguments.
method::asCompileString
Returns a string that will compile to return an Array equal to the receiver.
method::isValidUGenInput
Returns true. Arrays are valid UGen inputs.
method::asRawOSC
Returns the OSC message as an Int8Array. Receiver must be a bundle.
code::
[0.1, [\s_new, \default, -1, 1, 1, \freq, 1961]].asRawOSC;
::
|