File: SequenceableCollection.schelp

package info (click to toggle)
supercollider 1%3A3.13.0%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 80,292 kB
  • sloc: cpp: 476,363; lisp: 84,680; ansic: 77,685; sh: 25,509; python: 7,909; makefile: 3,440; perl: 1,964; javascript: 974; xml: 826; java: 677; yacc: 314; lex: 175; objc: 152; ruby: 136
file content (960 lines) | stat: -rw-r--r-- 36,305 bytes parent folder | download | duplicates (2)
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
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
CLASS::SequenceableCollection
summary::Abstract superclass of integer indexable collections
categories::Collections>Ordered

DESCRIPTION::
SequenceableCollection is a subclass of Collection whose elements can be indexed by an Integer. It has many useful subclasses; link::Classes/Array:: and link::Classes/List:: are amongst the most commonly used.

CLASSMETHODS::

copymethod:: Collection *fill

method::series
Fill a SequenceableCollection with an arithmetic series.
code::
Array.series(5, 10, 2);
::

method::geom
Fill a SequenceableCollection with a geometric series.
code::
Array.geom(5, 1, 3);
::

method::fib
Fill a SequenceableCollection with a fibonacci series.
code::
Array.fib(5);
Array.fib(5, 2, 32); // start from 32 with step 2.
::
argument::size
the number of values in the collection
argument::a
the starting step value
argument::b
the starting value

method::rand
Fill a SequenceableCollection with random values in the range strong::minVal:: to strong::maxVal::.
code::
Array.rand(8, 1, 100);
::

method::rand2
Fill a SequenceableCollection with random values in the range -strong::val:: to +strong::val::.
code::
Array.rand2(8, 100);
::

method::linrand
Fill a SequenceableCollection with random values in the range strong::minVal:: to strong::maxVal:: with a linear distribution.
code::
Array.linrand(8, 1, 100);
::

method::exprand
Fill a SequenceableCollection with random values in the range strong::minVal:: to strong::maxVal:: with exponential distribution.
code::
Array.exprand(8, 1, 100);
::

method::interpolation
Fill a SequenceableCollection with the interpolated values between the strong::start:: and strong::end:: values.
code::
Array.interpolation(5, 3.2, 20.5);
::



INSTANCEMETHODS::


method::|@|
synonym for link::Classes/ArrayedCollection#-clipAt::.
code::
[3, 4, 5]|@|6;
::

method::@@
synonym for link::Classes/ArrayedCollection#-wrapAt::.
code::
[3, 4, 5]@@6;
[3, 4, 5]@@ -1;
[3, 4, 5]@@[6, 8]
::

method::@|@
synonym for link::Classes/ArrayedCollection#-foldAt::.
code::
[3, 4, 5]@|@[6, 8];
::

method::first
Return the first element of the collection.
code::
[3, 4, 5].first;
::

method::last
Return the last element of the collection.
code::
[3, 4, 5].last;
::

method::putFirst, putLast
Place strong::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.
code::
[3, 4, 5].putFirst(100);
[3, 4, 5].putLast(100);
::

method::indexOf
Return the index of an strong::item:: in the collection, or nil if not found. Elements are checked for identity (not for equality).
code::
[3, 4, 100, 5].indexOf(100);
[3, 4, \foo, \bar].indexOf(\foo);
::

method::indexOfEqual
Return the index of something in the collection that equals the strong::item::, or nil if not found.
code::
[3, 4, "foo", "bar"].indexOfEqual("foo");
::

method::indicesOfEqual
Return an array of indices of things in the collection that equal the strong::item::, or nil if not found.
code::
y = [7, 8, 7, 6, 5, 6, 7, 6, 7, 8, 9];
y.indicesOfEqual(7);
y.indicesOfEqual(5);
::

method::indexOfGreaterThan
Return the first index containing an strong::item:: which is greater than strong::item::.
code::
y = List[ 10, 5, 77, 55, 12, 123];
y.indexOfGreaterThan(70);
::

method::selectIndices
Return a new collection of same type as receiver which consists of all indices of those elements of the receiver for which function answers code::true::. The function is passed two arguments, the item and an integer index.

code::
#[a, b, c, g, h, h, j, h].selectIndices({|item, i| item === \h})
::

If you want to control what type of collection is returned, use link::#-selectIndicesAs::

method::selectIndicesAs
Return a new collection of type emphasis::class:: which consists of all indices of those elements of the receiver for which function answers code::true::. The function is passed two arguments, the item and an integer index.

code::
#[a, b, c, g, h, h, j, h].selectIndicesAs({|item, i| item === \h}, Set)
::


method::rejectIndices
Return a new collection of same type as receiver which consists of all indices of those elements of the receiver for which function answers code::false::. The function is passed two arguments, the item and an integer index.

code::
#[a, b, c, g, h, h, j, h].rejectIndices({|item, i| item === \h})
::

If you want to control what type of collection is returned, use link::#-rejectIndicesAs::

method::rejectIndicesAs
Return a new collection of type emphasis::class:: which consists of all indices of those elements of the receiver for which function answers code::false::. The function is passed two arguments, the item and an integer index.

code::
#[a, b, c, g, h, h, j, h].rejectIndicesAs({|item, i| item === \h}, Set)
::

copymethod:: Collection -maxIndex

copymethod:: Collection -minIndex


method::find
If the strong::sublist:: exists in the receiver (in the specified order), at an offset greater than or equal to the initial strong::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).
code::
y = [7, 8, 7, 6, 5, 6, 7, 6, 7, 8, 9];
y.find([7, 6, 5]);
::

method::findAll
Similar to link::#-find:: but returns an array of all the indices at which the sequence is found.
code::
y = [7, 8, 7, 6, 5, 6, 7, 6, 7, 8, 9];
y.findAll([7, 6]);
::

method::indexIn
Returns the closest index of the value in the collection (collection must be sorted).
code::
[2, 3, 5, 6].indexIn(5.2);
::

method::indexInBetween
Returns a linearly interpolated float index for the value (collection must be sorted). Inverse operation is link::#-blendAt::.
code::
x = [2, 3, 5, 6].indexInBetween(5.2);
[2, 3, 5, 6].blendAt(x);
::

method::blendAt
Returns a linearly interpolated value between the two closest indices. Inverse operation is link::#-indexInBetween::.
code::
x = [2, 5, 6].blendAt(0.4);
::

method::copyRange
Return a new SequenceableCollection which is a copy of the indexed slots of the receiver from strong::start:: to strong::end::. If strong::end:: < strong::start::, an empty collection is returned.
code::
(
var y, z;
z = [1, 2, 3, 4, 5];
y = z.copyRange(1, 3);
z.postln;
y.postln;
)
::
warning:: code::x.copyRange(a, b):: is strong::not:: equivalent to code::x[a..b]::. The latter compiles to link::Classes/ArrayedCollection#-copySeries::, which has different behavior when strong::end:: < strong::start::. ::

method::copyToEnd
Return a new SequenceableCollection which is a copy of the indexed slots of the receiver from strong::start:: to the end of the collection.
code::x.copyToEnd(a):: can also be written as code::x[a..]::

method::copyFromStart
Return a new SequenceableCollection which is a copy of the indexed slots of the receiver from the start of the collection to strong::end::.
code::x.copyFromStart(a):: can also be written as code::x[..a]::

method::remove
Remove strong::item:: from collection. Elements are checked for identity (not for equality).

method::take
Remove and return strong::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 link::Classes/ArrayedCollection#-takeAt::. Elements are checked for identity (not for equality).
warning:: code::take(item):: works on Arrays but not on Lists, because the internally called method code::takeAt(item):: is not defined for Lists. ::
code::
a = [11, 12, 13, 14, 15];
a.take(12);
a;
::

method::obtain
Retrieve an element from a given index (like link::Classes/SequenceableCollection#-at::). This method is also implemented in link::Classes/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: link::Classes/SequenceableCollection#-instill::

argument::index
The index at which to look for an element

argument::default
If index exceeds collection size, or receiver is nil, return this instead

code::
(
a = [10, 20, 30];
b = [10, 20];
c = 7;
);

 // obtain third element, if outside bounds return 1
a.obtain(2, 1);
b.obtain(2, 1);
c.obtain(2, 1);
::

method::instill
Put an element at a given index (like link::Classes/SequenceableCollection#-put::). This method is also implemented in link::Classes/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: link::Classes/SequenceableCollection#-obtain::

argument::index
The index at which to put the item

argument::item
The object to put into the new collection

argument::default
If the index exceeds the current collection's size, extend the collection with this element

code::
(
a = [10, 20, 30, 40];
b = [10, 20];
c = 7;
);

a.instill(2, -1);
b.instill(2, -1);
c.instill(2, -1);
// providing a default value
c.instill(2, -1, 0);
::

method::keep
Keep the first strong::n:: items of the array. If strong::n:: is negative, keep the last -strong::n:: items.
code::
a = [1, 2, 3, 4, 5];
a.keep(3);
a.keep(-3);
::

method::drop
Drop the first strong::n:: items of the array. If strong::n:: is negative, drop the last -strong::n:: items.
code::
a = [1, 2, 3, 4, 5];
a.drop(3);
a.drop(-3);
::

method::join
Returns a link::Classes/String:: formed by connecting all the elements of the receiver, with strong::joiner:: inbetween. See also link::Classes/String#-split:: as the complementary operation.
code::
["m", "ss", "ss", "pp", ""].join("i").postcs;
"mississippi".split("i").postcs;
::

method::flat
Returns a collection from which all nesting has been flattened.
code::
[[1, 2, 3], [[4, 5], [[6]]]].flat; // [ 1, 2, 3, 4, 5, 6 ]
[1, 2, [3, 4, [5, 6, [7, 8, [9, 0]]]]].flat; // [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 ]
::

method::flatten
Returns a collection from which strong::numLevels:: of nesting has been flattened.

argument::numLevels
Specifies how many levels downward (inward) to flatten. Zero returns the original.

code::
a = [1, 2, [3, 4, [5, 6, [7, 8, [9, 0]]]]];
a.flatten(1); // [ 1, 2, [ 3, 4, [ 5, 6, [ 7, 8, [ 9, 0 ] ] ] ] ]
a.flatten(2); // [ 1, 2, 3, 4, 5, 6, [ 7, 8, [ 9, 0 ] ] ]
a.flatten(3); // [ 1, 2, 3, 4, 5, 6, 7, 8, [ 9, 0 ] ]
a.flatten(4); // [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 ]
::


method::flatten2
A symmetric version of link::#-flatten::. For a negative code::numLevels::, it flattens starting from the innermost arrays.

argument::numLevels
Specifies how many levels downward (inward) or upward (outward) to flatten.

code::
a = [1, 2, [3, 4, [5, 6, [7, 8, [9, 0]]]]];
a.flatten2(4);  // [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 ]
a.flatten2(3);  // [ 1, 2, 3, 4, 5, 6, 7, 8, [ 9, 0 ] ]
a.flatten2(2);  // [ 1, 2, 3, 4, 5, 6, [ 7, 8, [ 9, 0 ] ] ]
a.flatten2(1);  // [ 1, 2, 3, 4, [ 5, 6, [ 7, 8, [ 9, 0 ] ] ] ]
a.flatten2(0);  // [ 1, 2, [ 3, 4, [ 5, 6, [ 7, 8, [ 9, 0 ] ] ] ] ]
a.flatten2(-1); // [ 1, 2, [ 3, 4, [ 5, 6, [ 7, 8, 9, 0 ] ] ] ]
a.flatten2(-2); // [ 1, 2, [ 3, 4, [ 5, 6, 7, 8, 9, 0 ] ] ]
a.flatten2(-3); // [ 1, 2, [ 3, 4, 5, 6, 7, 8, 9, 0 ] ]
a.flatten2(-4); // [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 ]
::



method::flatBelow
Flatten all subarrays deeper than strong::level::.

argument::level
Specifies from what level onward to flatten.
level 0 is outermost, so flatBelow(0) is like flat.

code::
a = [1, 2, [3, 4, [5, 6, [7, 8, [9, 0]]]]];
a.flatBelow(0); // [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 ]
a.flatBelow(1); // [ 1, 2, [ 3, 4, 5, 6, 7, 8, 9, 0 ] ]
a.flatBelow(2); // [ 1, 2, [ 3, 4, [ 5, 6, 7, 8, 9, 0 ] ] ]

// to set the level below which to flatten from the deepest level up,
// one can use coll.maxDepth. E.g. to flatten only the innermost level:
a.flatBelow( (a.maxDepth - 1) - 1);
// for lowest two levels:
a.flatBelow( (a.maxDepth - 1) - 2);
::



method::flop
Invert rows and columns in a two dimensional Collection (turn inside out). See also: link::Classes/Function::.
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.
::
Note that the innermost arrays are not copied:
code::
a = [1, 2];
x = [[[a, 5], [a, 10]], [[a, 50, 60]]].flop;
a[0] = pi;
x // pi is everywhere
::


method::flopWith
Flop with a user defined function. Can be used to collect over several collections in parallel.
code::
[[1, 2, 3], [4, 5, 6]].flopWith(_+_);
[[1, 2, 3], 1, [7, 8]].flopWith{ |a,b,c| a+b+c }; // shorter array wraps

// typical use case (pseudocode)
[synths, buffers].flopWith{ |a,b| a.set(\buf, b) }
::
argument::func
A function taking as many arguments as elements in the array.

method::flopTogether
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.
code::
(
a = flopTogether(
	[[1, 2, 3], [4, 5, 6, 7, 8]] * 100,
	[[1, 2, 3], [4, 5, 6], [7, 8]],
	[1000]
)
);

a.collect(_.size); // sizes are the same
a.collect(_.shape) // shapes can be different
::


method::flopDeep
Fold dimensions in a multi-dimensional Collection (turn inside out).

argument::rank
The depth (dimension) from which the array is inverted inside-out.

code::
[[1, 2, 3], [[41, 52], 5, 6]].flopDeep(2);
[[1, 2, 3], [[41, 52], 5, 6]].flopDeep(1);
[[1, 2, 3], [[41, 52], 5, 6]].flopDeep(0);
[[1, 2, 3], [[41, 52], 5, 6]].flopDeep; // without argument, flop from the deepest level

[[[10, 100, 1000], 2, 3], [[41, 52], 5, 6]].flopDeep(2); // shorter array wraps
[].flopDeep(1); // result is always one dimension higher.
[[]].flopDeep(4);
::

note::Note that, just like in flop, the innermost arrays (deeper than rank) are not copied.::

code::
a = [1, 2];
x = [[[a, 5], [a, 10]], [[a, 50, 60]]].flopDeep(1);
a[0] = pi;
x // pi is everywhere
::

method::maxSizeAtDepth
Returns the maximum size of all subarrays at a certain depth (dimension)

argument::rank
The depth at which the size of the arrays is measured

code::
[[1, 2, 3], [[41, 52], 5, 6], 1, 2, 3].maxSizeAtDepth(2);
[[1, 2, 3], [[41, 52], 5, 6], 1, 2, 3].maxSizeAtDepth(1);
[[1, 2, 3], [[41, 52], 5, 6], 1, 2, 3].maxSizeAtDepth(0);
[].maxSizeAtDepth(0);
[[]].maxSizeAtDepth(0);
[[]].maxSizeAtDepth(1);
::

method::maxDepth
Returns the maximum depth of all subarrays.

argument::max
Internally used only.

code::
[[1, 2, 3], [[41, 52], 5, 6], 1, 2, 3].maxDepth
::

method::isSeries
Returns true if the collection is an arithmetic series.

argument::step
Step size to look for. If none is given, any step size will match.

code::
[ 0, 1, 2, 3, 4, 5 ].isSeries; // true
[ 1.5, 2.5, 3.5, 4.5, 5.5, 6.5 ].isSeries; // true
[ 0, 1, 4, 5 ].isSeries; // false
[ 0, 3, 6, 9, 12, 15 ].isSeries; // true
[ 0, 3, 6, 9, 12, 15 ].isSeries(1); // false
[ 2 ] // true
[ ] // true (empty sequence)
::

method::resamp0
Returns a new Collection of the desired length, with values resampled evenly-spaced from the receiver without interpolation.
code::
[1, 2, 3, 4].resamp0(12);
[1, 2, 3, 4].resamp0(2);
::

method::resamp1
Returns a new Collection of the desired length, with values resampled evenly-spaced from the receiver with linear interpolation.
code::
[1, 2, 3, 4].resamp1(12);
[1, 2, 3, 4].resamp1(3);
::

method::choose
Choose an element from the collection at random.
code::
[1, 2, 3, 4].choose;
::

method::wchoose
Choose an element from the collection at random using a list of probabilities or weights. The weights must sum to 1.0.
code::
[1, 2, 3, 4].wchoose([0.1, 0.2, 0.3, 0.4]);
::

method::sort
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 }
code::
[6, 2, 1, 7, 5].sort;
[6, 2, 1, 7, 5].sort({ arg a, b; a > b }); // reverse sort
::

method::sortBy
Sort the contents of the collection using the key strong::key::, which is assumed to be found inside each element of the receiver.
code::
(
a = [
	Dictionary[\a->5, \b->1, \c->62],
	Dictionary[\a->2, \b->9, \c->65],
	Dictionary[\a->8, \b->5, \c->68],
	Dictionary[\a->1, \b->3, \c->61],
	Dictionary[\a->6, \b->7, \c->63]
]
)
a.sortBy(\b);
a.sortBy(\c);
::

method::order
Return an array of indices that would sort the collection into order. strong::function:: is treated the same way as for the link::#-sort:: method.
code::
[6, 2, 1, 7, 5].order;
::

method::swap
Swap two elements in the collection at indices strong::i:: and strong::j::.

method::pairsDo
Calls function for each subsequent pair of elements in the SequentialCollection. The function is passed the two elements and an index.
code::
[1, 2, 3, 4, 5].pairsDo({ arg a, b; [a, b].postln; });
::

method::doAdjacentPairs
Calls function for every adjacent pair of elements in the SequenceableCollection. The function is passed the two adjacent elements and an index.
code::
[1, 2, 3, 4, 5].doAdjacentPairs({ arg a, b; [a, b].postln; });
::

method::separate
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.
code::
[1, 2, 3, 5, 6, 8, 10].separate({ arg a, b; (b - a) > 1 }).postcs;
::

method::clump
Separates the collection into sub-collections by separating every groupSize elements.
code::
[1, 2, 3, 4, 5, 6, 7, 8].clump(3).postcs;
::

method::clumps
Separates the collection into sub-collections by separating elements into groupings whose size is given by integers in the groupSizeList.
code::
[1, 2, 3, 4, 5, 6, 7, 8].clumps([1, 2]).postcs;
::

method::curdle
Separates the collection into sub-collections by randomly separating elements according to the given probability.
code::
[1, 2, 3, 4, 5, 6, 7, 8].curdle(0.3).postcs;
::

method::integrate
Returns a collection with the incremental sums of all elements.
code::
[3, 4, 1, 1].integrate;
::

method::differentiate
Returns a collection with the pairwise difference between all elements.
code::
[3, 4, 1, 1].differentiate;
::

method::reduce
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 code::nil::.

argument::operator
May be a link::Classes/Function:: (taking two or three arguments) or a link::Classes/Symbol:: (method selector).


code::
[3, 4, 5, 6].reduce('*'); // this is the same as [3, 4, 5, 6].product
[3, 4, 5, 6].reduce(\lcm); // Lowest common multiple of the whole set of numbers
["d", "e", (0..9), "h"].reduce('++'); // concatenation
[3, 4, 5, 6].reduce({ |a, b| sin(a) * sin(b) }); // product of sines
::


argument::adverb
An optional adverb to be used together with the operator (see link::Reference/Adverbs::). If the operator is a functions, the adverb is passed as a third argument.

code::
// compare:
[1, 2] *.x [10, 20, 30]
[[1, 2], [10, 20, 30]].reduce('*', 'x')
[[1, 2], [10, 20, 30], [1000, 2000]].reduce('+', 'x') // but you can combine more
::

method::convertDigits
Returns an integer resulting from interpreting the elements as digits to a given base (default 10). See also asDigits in link::Classes/Integer#-asDigits:: for the complementary method.
code::
[1, 0, 0, 0].convertDigits;
[1, 0, 0, 0].convertDigits(2);
[1, 0, 0, 0].convertDigits(3);
::

method::hammingDistance
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.

code::
[0, 0, 0, 1, 1, 1, 0, 1, 0, 0].hammingDistance([0, 0, 1, 1, 0, 0, 0, 0, 1, 1]);
"SuperMan".hammingDistance("SuperCollider");
::

subsection:: Fuzzy comparisons
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.

method::editDistance
Returns the minimum number of changes to modify this teletype::SequenceableCollection:: into the other teletype::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 strong::identity:: - see link::Classes/Object#-==:: and link::Classes/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.

code::
"hello".editDistance("hallo"); // 1 (substitution)
"hello".editDistance("hell"); // 1 (deletion)
"hello".editDistance("helloo"); // 1 (addition)
"hello".editDistance("hllo"); // 1 (removal)
"hello".editDistance("haldo"); // 2 (substitutions)
::

In cases where the arrays are of different types, it will fall back to a slower, non-primitive implementation.

code::
// String vs Array
"hello".editDistance([$h, $e, $l, $l, $o]);
::

For cases that require comparisons other than identity, the optional teletype::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.

code::
// Using compareFunc for case insensitive comparisons
"HeLLO".editDistance("HELLO", { |a, b|
	a.toLower == b.toLower;
});
::

note::
Specifying a teletype::compareFunc:: will bypass the primitive and may take significantly longer to execute for larger arrays.
::

argument::other
The teletype::SequenceableCollection:: to compare against

argument::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 teletype::nil::, which will use strong::identity:: (not equality) to compare elements.

code::
[1,2,3,4].editDistance([2,3,4,5], { | a, b |
	a == b;
});
::

method::similarity
Returns a value between 0 and 1 representing the percentage similarity between this teletype::SequenceableCollection:: and the other teletype::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 link::#-editDistance::
code::
"hello".similarity("hello"); // 1
"hello".similarity("asdf"); // 0
"word".similarity("wodr"); // 0.5
::

argument::other
The code::SequenceableCollection:: to compare against

argument::compareFunc
An optional compareFunc to be used to calculate the edit distance (see link::#-editDistance::)

private::prEditDistance
private::prLevenshteinDistance

subsection::Math Support - Unary Messages

All of the following messages send the message link::#-performUnaryOp:: to the receiver with the unary message selector as an argument.

method::neg, reciprocal, bitNot, abs, asFloat, ceil, floor, frac, sign, squared, cubed, sqrt, exp, midicps, cpsmidi, midiratio, ratiomidi, ampdb, dbamp, octcps, cpsoct, log, log2, log10, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, rand, rand2, linrand, bilinrand, sum3rand, distort, softclip, coin, even, odd, isPositive, isNegative, isStrictlyPositive, real, imag, magnitude, magnitudeApx, phase, angle, rho, theta, asFloat, asInteger

method::performUnaryOp
Creates a new collection of the results of applying the selector to all elements in the receiver.
code::
[1, 2, 3, 4].neg;
[1, 2, 3, 4].reciprocal;
::

subsection::Math Support - Binary Messages

All of the following messages send the message link::#-performBinaryOp:: to the receiver with the binary message selector and the second operand as arguments.

method:: +, -, *, /, div, min, max, <, <=, >, >=, bitXor, lcm, gcd, round, trunc, atan2, hypot, ring1, ring2, ring3, ring4, difsqr, sumsqr, sqrdif, absdif, amclip, scaleneg, clip2, excess, rrand, exprand

method:: %, **, &, |, >>, +>>, <!

method::performBinaryOp
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.
code::
([1, 2, 3, 4] * 10);
([1, 2, 3, 4] * [4, 5, 6, 7]);
::

subsection::Math Support - Special Functions

A variety of Special Functions are supplied by the Boost C++ library. The library's
link::http://www.boost.org/doc/libs/1_66_0/libs/math/doc/html/special.html##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 link::Guides/Tour-of-Special-Functions::.

note::The following methods are documented slightly clearer in
link::Classes/SimpleNumber#Special Functions:: using functional notation.
As of this writing, a bug in the help file formatting misleadingly documents
the methods in receiver notation (methods preceded by code::.::), but should
be read to suggests the usage: code::foo([a], [b])::. The equivalent receiver
notation is: code::[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. code::foo([a]):: or code::[a].foo::::

warning::Many of the functions are only valid in certain numerical ranges. For the most part, error handling
happens in the underlying boost functions. While these errors are often obtuse, you'll usually find
a useful message at the end of the error regarding proper ranges and the erroneous value supplied.
Refer to the online documentation for more detailed descriptions, and the
link::Guides/Tour-of-Special-Functions:: for plots showing ranges and asymptotes.::

copymethod:: SimpleNumber -bernouliB2n
copymethod:: SimpleNumber -tangentT2n
copymethod:: SimpleNumber -tgamma
copymethod:: SimpleNumber -tgamma1pm1
copymethod:: SimpleNumber -lgamma
copymethod:: SimpleNumber -digamma
copymethod:: SimpleNumber -trigamma
copymethod:: SimpleNumber -polygamma
copymethod:: SimpleNumber -tgammaRatio
copymethod:: SimpleNumber -tgammaDeltaRatio
copymethod:: SimpleNumber -gammaP
copymethod:: SimpleNumber -gammaQ
copymethod:: SimpleNumber -tgammaLower
copymethod:: SimpleNumber -tgammaUpper
copymethod:: SimpleNumber -gammaPInv
copymethod:: SimpleNumber -gammaQInv
copymethod:: SimpleNumber -gammaPInvA
copymethod:: SimpleNumber -gammaQInvA
copymethod:: SimpleNumber -gammaPDerivative
copymethod:: SimpleNumber -gammaQDerivative
copymethod:: SimpleNumber -factorial
copymethod:: SimpleNumber -doubleFactorial
copymethod:: SimpleNumber -risingFactorial
copymethod:: SimpleNumber -fallingFactorial
copymethod:: SimpleNumber -binomialCoefficient
copymethod:: SimpleNumber -beta
copymethod:: SimpleNumber -ibeta
copymethod:: SimpleNumber -ibetaC
copymethod:: SimpleNumber -betaFull
copymethod:: SimpleNumber -betaFullC
copymethod:: SimpleNumber -ibetaInv
copymethod:: SimpleNumber -ibetaCInv
copymethod:: SimpleNumber -ibetaInvA
copymethod:: SimpleNumber -ibetaCInvA
copymethod:: SimpleNumber -ibetaInvB
copymethod:: SimpleNumber -ibetaCInvB
copymethod:: SimpleNumber -ibetaDerivative
copymethod:: SimpleNumber -erf
copymethod:: SimpleNumber -erfC
copymethod:: SimpleNumber -erfInv
copymethod:: SimpleNumber -erfCInv
copymethod:: SimpleNumber -legendreP
copymethod:: SimpleNumber -legendrePPrime
copymethod:: SimpleNumber -legendrePZeros
copymethod:: SimpleNumber -legendrePAssoc
copymethod:: SimpleNumber -legendreQ
copymethod:: SimpleNumber -laguerre
copymethod:: SimpleNumber -laguerreAssoc
copymethod:: SimpleNumber -hermite
copymethod:: SimpleNumber -chebyshevT
copymethod:: SimpleNumber -chebyshevU
copymethod:: SimpleNumber -chebyshevTPrime
copymethod:: SimpleNumber -chebyshevTZeros
copymethod:: SimpleNumber -sphericalHarmonic
copymethod:: SimpleNumber -sphericalHarmonicR
copymethod:: SimpleNumber -sphericalHarmonicI
copymethod:: SimpleNumber -cylBesselJ
copymethod:: SimpleNumber -cylNeumann
copymethod:: SimpleNumber -cylBesselJZero
copymethod:: SimpleNumber -cylNeumannZero
copymethod:: SimpleNumber -cylBesselI
copymethod:: SimpleNumber -cylBesselK
copymethod:: SimpleNumber -sphBessel
copymethod:: SimpleNumber -sphNeumann
copymethod:: SimpleNumber -cylBesselJPrime
copymethod:: SimpleNumber -cylNeumannPrime
copymethod:: SimpleNumber -cylBesselIPrime
copymethod:: SimpleNumber -cylBesselKPrime
copymethod:: SimpleNumber -sphBesselPrime
copymethod:: SimpleNumber -sphNeumannPrime
copymethod:: SimpleNumber -cylHankel1
copymethod:: SimpleNumber -cylHankel2
copymethod:: SimpleNumber -sphHankel1
copymethod:: SimpleNumber -sphHankel2
copymethod:: SimpleNumber -airyAi
copymethod:: SimpleNumber -airyBi
copymethod:: SimpleNumber -airyAiPrime
copymethod:: SimpleNumber -airyBiPrime
copymethod:: SimpleNumber -airyAiZero
copymethod:: SimpleNumber -airyBiZero
copymethod:: SimpleNumber -ellintRf
copymethod:: SimpleNumber -ellintRd
copymethod:: SimpleNumber -ellintRj
copymethod:: SimpleNumber -ellintRc
copymethod:: SimpleNumber -ellintRg
copymethod:: SimpleNumber -ellint1
copymethod:: SimpleNumber -ellint1C
copymethod:: SimpleNumber -ellint2
copymethod:: SimpleNumber -ellint2C
copymethod:: SimpleNumber -ellint3
copymethod:: SimpleNumber -ellint3C
copymethod:: SimpleNumber -ellintD
copymethod:: SimpleNumber -ellintDC
copymethod:: SimpleNumber -jacobiZeta
copymethod:: SimpleNumber -heumanLambda
copymethod:: SimpleNumber -jacobiCd
copymethod:: SimpleNumber -jacobiCn
copymethod:: SimpleNumber -jacobiCs
copymethod:: SimpleNumber -jacobiDc
copymethod:: SimpleNumber -jacobiDn
copymethod:: SimpleNumber -jacobiDs
copymethod:: SimpleNumber -jacobiNc
copymethod:: SimpleNumber -jacobiNd
copymethod:: SimpleNumber -jacobiNs
copymethod:: SimpleNumber -jacobiSc
copymethod:: SimpleNumber -jacobiSd
copymethod:: SimpleNumber -jacobiSn
copymethod:: SimpleNumber -zeta
copymethod:: SimpleNumber -expintEn
copymethod:: SimpleNumber -expintEi
copymethod:: SimpleNumber -sinPi
copymethod:: SimpleNumber -cosPi
copymethod:: SimpleNumber -log1p
copymethod:: SimpleNumber -expm1
copymethod:: SimpleNumber -cbrt
copymethod:: SimpleNumber -sqrt1pm1
copymethod:: SimpleNumber -powm1
copymethod:: SimpleNumber -sincPi
copymethod:: SimpleNumber -sinhcPi
copymethod:: SimpleNumber -asinh
copymethod:: SimpleNumber -acosh
copymethod:: SimpleNumber -atanh
copymethod:: SimpleNumber -owensT


subsection::Multichannel wrappers
All of the following messages are performed on the elements of this collection, using link::Classes/Object#-multiChannelPerform::.

The result depends on the objects in the collection, but the main use case is for link::Classes/UGen::s.

See also link::Guides/Multichannel-Expansion::

method::clip, wrap, fold, prune, linlin, linexp, explin, expexp, lincurve, curvelin, bilin, biexp, range, exprange, unipolar, bipolar, lag, lag2, lag3, lagud, lag2ud, lag3ud, varlag, slew, blend, checkBadValues
Calls code:: this.multiChannelPerform(selector, *args) :: where selector is the name of the message.

method::multichannelExpandRef
This method is called internally on inputs to UGens that take multidimensional arrays, like link::Classes/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 link::Classes/Ref:: for the corresponding method implementation.
argument::rank
The depth at which the list is expanded. For instance the Klank spec has a rank of 2. For more examples, see link::Classes/SequenceableCollection#-flopDeep::
code::
`([[[100, 200], 500], nil, [[[0.01, 0.3], 0.8]]]).multichannelExpandRef(2);
[`[[100, 200], nil, [0.2, 0.8]], `[[130, 202], nil, [0.2, 0.5]]].multichannelExpandRef(2);
::

subsection:: Rhythm-lists
method:: convertRhythm
Convert a rhythm-list to durations.
discussion::
supports a variation of Mikael Laurson's rhythm list RTM-notation. footnote::
see Laurson and Kuuskankare's 2003, "From RTM-notation to ENP-score-notation"
http://jim2003.agglo-montbeliard.fr/articles/laurson.pdf
::

The method converts a collection of the form code:: [beat-count, [rtm-list], repeats] :: to a link::Classes/List:: of link::Classes/Float::s. 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.
code::
// using numbers as score
[3, [1, 2, 1], 1].convertRhythm; // List[ 0.75, 1.5, 0.75 ]
[2, [1, 3, [1, [2, 1, 1, 1]], 1, 3], 1].convertRhythm;
[2, [1, [1, [2, 1, 1, 1]]], 1].convertRhythm;
[2, [1, [1, [2, 1, 1, 1]]], 2].convertRhythm; // repeat
[2, [1, [1, [2, 1, 1, -1]]], 2].convertRhythm; // negative value is tied over.

// sound example
Pbind(\degree, Pseries(0, 1, inf), \dur, Pseq([2, [1, [1, [2, 1, 1, -1]]], 2].convertRhythm)).play;
::

subsection:: Starting UNIX processes

private::prUnixCmd

method::unixCmd
Execute a UNIX command strong::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.
argument:: action
A link::Classes/Function:: that is called when the process has exited. It is passed two arguments: the exit code and pid of the exited process.
argument:: postOutput
A link::Classes/Boolean:: that controls whether or not the output of the process is displayed in the post window.
returns::
An link::Classes/Integer:: - the pid of the newly created process. Use link::Classes/Integer#-pidRunning:: to test if a process is alive.
discussion::
Example:
code::
["ls","/"].unixCmd;
::

method::unixCmdGetStdOut
Similar to link::#-unixCmd:: except that the stdout of the process is returned (strong::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.
code::
~listing = ["ls","/"].unixCmdGetStdOut; // Grab
~listing.reverse.as(Array).dupEach.join.postln; // Mangle
::

private:: acosh, airyAi, airyAiPrime, airyAiZero, acosh, airyAi, airyAiPrime, airyAiZero, airyBi, airyBiPrime, airyBiZero, asinh, atanh, bernouliB2n, beta, betaFull, betaFullC, binomialCoefficient, cbrt, chebyshevT, chebyshevTPrime, chebyshevTZeros, chebyshevU, cosPi, cylBesselI, cylBesselIPrime, cylBesselJ, cylBesselJPrime, cylBesselJZero, cylBesselK, cylBesselKPrime, cylHankel1, cylHankel2, cylNeumann, cylNeumannPrime, cylNeumannZero, digamma, doubleFactorial, ellint1, ellint1C, ellint2, ellint2C, ellint3, ellint3C, ellintD, ellintDC, ellintRc, ellintRd, ellintRf, ellintRg, ellintRj, erf, erfC, erfCInv, erfInv, expintEi, expintEn, expm1, factorial, fallingFactorial, gammaP, gammaPDerivative, gammaPInv, gammaPInvA, gammaQ, gammaQDerivative, gammaQInv, gammaQInvA, hermite, heumanLambda, ibeta, ibetaC, ibetaCInv, ibetaCInvA, ibetaCInvB, ibetaDerivative, ibetaInv, ibetaInvA, ibetaInvB, jacobiCd, jacobiCn, jacobiCs, jacobiDc, jacobiDn, jacobiDs, jacobiNc, jacobiNd, jacobiNs, jacobiSc, jacobiSd, jacobiSn, jacobiZeta, laguerre, laguerreAssoc, legendreP, legendrePAssoc, legendrePPrime, legendrePZeros, legendreQ, lgamma, log1p, owensT, polygamma, pow, powm1, prHermite, prLaguerreAssoc, prLegendreQ, risingFactorial, sinPi, sincPi, sinhcPi, sphBessel, sphBesselPrime, sphHankel1, sphHankel2, sphNeumann, sphNeumannPrime, sphericalHarmonic, sphericalHarmonicI, sphericalHarmonicR, sqrt1pm1, tangentT2n, tgamma, tgamma1pm1, tgammaDeltaRatio, tgammaLower, tgammaRatio, tgammaUpper, trigamma, zeta