1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"1038.25">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica
; min-height: 17.0px}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica
}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica
; min-height: 14.0px}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica
}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; min-height: 12.0px}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Monaco
; min-height: 16.0px}
19 p
.p10
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; color: #000000}
20 p
.p11
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica
; color: #000000; min-height: 14.0px}
21 p
.p12
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; color: #606060}
22 p
.p13
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; color: #606060; min-height: 12.0px}
23 p
.p14
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; color: #bf0000}
24 p
.p15
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; color: #bf0000; min-height: 12.0px}
25 p
.p16
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 6.0px Monaco
; min-height: 9.0px}
26 p
.p17
{margin: 0.0px 0.0px 0.0px 42.0px; font: 12.0px Monaco
; min-height: 16.0px}
27 p
.p18
{margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica
}
28 p
.p19
{margin: 0.0px 0.0px 0.0px 42.0px; font: 12.0px Helvetica
; min-height: 14.0px}
29 p
.p20
{margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica
; min-height: 17.0px}
30 span
.s1
{font: 18.0px Helvetica
}
31 span
.s2
{color: #0000bf}
32 span
.s3
{font: 9.0px Monaco
}
33 span
.s4
{font: 12.0px Helvetica
}
34 span
.s5
{font: 12.0px Monaco
}
35 span
.s6
{color: #000000}
36 span
.s7
{color: #00831b}
37 span
.s8
{font: 12.0px Helvetica
; color: #000000}
38 span
.s9
{color: #737373}
39 span
.s10
{color: #bf0000}
40 span
.s11
{font: 9.0px Monaco
; color: #bf0000}
41 span
.s12
{color: #606060}
42 span
.s13
{color: #007300}
43 span
.s14
{font: 9.0px Helvetica
}
44 span
.s15
{font: 6.0px Monaco
}
45 span
.s16
{text-decoration: underline
}
46 span
.Apple-tab-span
{white-space:pre
}
50 <p class=
"p1"><span class=
"s1"><b>SequenceableCollection
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></span><b>integer indexable collection
</b></p>
51 <p class=
"p2"><br></p>
52 <p class=
"p1"><b>Inherits from:
</b><a href=
"../Core/Object.html"><span class=
"s2"><b>Object
</b></span></a><b> :
</b><a href=
"Collection.html"><span class=
"s2"><b>Collection
</b></span></a></p>
53 <p class=
"p2"><br></p>
54 <p class=
"p1">SequenceableCollection is a subclass of Collection whose elements can be indexed by an Integer. It has many useful subclasses;
<a href=
"Array.html"><span class=
"s2"><b>Array
</b></span></a> and
<a href=
"List.html"><span class=
"s2"><b>List
</b></span></a> are amongst the most commonly used.
</p>
55 <p class=
"p2"><br></p>
56 <p class=
"p3"><br></p>
57 <p class=
"p4"><b>Class Methods
</b></p>
58 <p class=
"p5"><br></p>
59 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>*series(size, start, step)
</b></p>
60 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Fill a SequenceableCollection with an arithmetic series.
</p>
61 <p class=
"p5"><br></p>
62 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span>Array
</span>.series(
5,
10,
2);
</p>
63 <p class=
"p5"><br></p>
64 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>*geom(size, start, grow)
</b></p>
65 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Fill a SequenceableCollection with a geometric series.
</p>
66 <p class=
"p5"><br></p>
67 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span>Array
</span>.geom(
5,
1,
3);
</p>
68 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
69 <p class=
"p6"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span><b>*fib(size, a, b)
</b></p>
70 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Fill a SequenceableCollection with a fibonacci series.
<span class=
"Apple-converted-space"> </span></p>
71 <p class=
"p6"><span class=
"Apple-tab-span"> </span>b is the starting value (default:
1), a is the starting step value (default:
0)
</p>
72 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
73 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span><span class=
"s2">Array
</span>.fib(
5);
</p>
74 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"s2">Array
</span>.fib(
5,
2,
32); // start from
32 with step
2.
</p>
75 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
76 <p class=
"p6"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span><b>*rand(size, minVal, maxVal)
</b></p>
77 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Fill a SequenceableCollection with random values in the range minVal to maxVal.
</p>
78 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
79 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span><span class=
"s2">Array
</span>.rand(
8,
1,
100);
</p>
80 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
81 <p class=
"p6"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span><b>*rand2(size, val)
</b></p>
82 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Fill a SequenceableCollection with random values in the range -val to +val.
</p>
83 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
84 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span><span class=
"s2">Array
</span>.rand2(
8,
100);
</p>
85 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
86 <p class=
"p6"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span><b>*linrand(size, minVal, maxVal)
</b></p>
87 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Fill a SequenceableCollection with random values in the range minVal to maxVal with a linear distribution.
</p>
88 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
89 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span><span class=
"s2">Array
</span>.linrand(
8,
1,
100);
</p>
90 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
91 <p class=
"p6"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span><b>*exprand(size, minVal, maxVal)
</b></p>
92 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Fill a SequenceableCollection with random values in the range minVal to maxVal with exponential
</p>
93 <p class=
"p6"><span class=
"Apple-tab-span"> </span>distribution.
</p>
94 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
95 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span><span class=
"s2">Array
</span>.exprand(
8,
1,
100);
</p>
96 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
97 <p class=
"p6"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span><b>*interpolation(size, start, end)
</b></p>
98 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Fill a SequenceableCollection with the interpolated values between the start and end values.
</p>
99 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
100 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span><span class=
"s2">Array
</span>.interpolation(
5,
3.2,
20.5);
</p>
101 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
102 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
103 <p class=
"p4"><b>Instance Methods
</b></p>
104 <p class=
"p3"><span class=
"Apple-tab-span"> </span></p>
105 <p class=
"p6"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span><b>first
</b></p>
106 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Return the first element of the collection.
</p>
107 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
108 <p class=
"p7"><span class=
"Apple-tab-span"> </span>[
3,
4,
5].first;
</p>
109 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
110 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>last
</b></p>
111 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Return the last element of the collection.
</p>
112 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
113 <p class=
"p7"><span class=
"Apple-tab-span"> </span>[
3,
4,
5].last;
</p>
114 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
115 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>putFirst(item)
</b></p>
116 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>putLast(item)
</b></p>
117 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Place
<b>item
</b> 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.
</p>
118 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
119 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>[
3,
4,
5].putFirst(
100);
</p>
120 <p class=
"p7"><span class=
"Apple-tab-span"> </span>[
3,
4,
5].putLast(
100);
</p>
121 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
122 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>indexOf(item)
</b></p>
123 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Return the index of an item in the collection, or nil if not found.
</p>
124 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
125 <p class=
"p10"><span class=
"s6"><span class=
"Apple-tab-span"> </span></span><span class=
"Apple-tab-span"> </span>[
3,
4,
100,
5].indexOf(
100);
</p>
126 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>[
3,
4,
<span class=
"s7">\foo
</span>,
<span class=
"s7">\bar
</span>].indexOf(
<span class=
"s7">\foo
</span>);
</p>
127 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
128 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>indexOfEqual(item)
</b></p>
129 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Return the index of something in the collection that equals the item, or nil if not found.
</p>
130 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
131 <p class=
"p10"><span class=
"s8"><span class=
"Apple-tab-span"> </span></span><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>[
3,
4,
<span class=
"s9">"foo"</span>,
<span class=
"s9">"bar"</span>].indexOfEqual(
<span class=
"s9">"foo"</span>);
</p>
132 <p class=
"p11"><span class=
"Apple-tab-span"> </span></p>
133 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>indicesOfEqual(item)
</b></p>
134 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Return an array of indices of things in the collection that equal the item, or nil if not found.
</p>
135 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
136 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>y = [
7,
8,
7,
6,
5,
6,
7,
6,
7,
8,
9]
</p>
137 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>y.indicesOfEqual(
7);
</p>
138 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>y.indicesOfEqual(
5);
</p>
139 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
140 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>indexOfGreaterThan(item)
</b></p>
141 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Return the first index containing an item which is greater than
<b>item
</b>.
</p>
142 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
143 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span><span class=
"Apple-tab-span"> </span>y =
<span class=
"s2">List
</span>[
10,
5,
77,
55,
12,
123];
<span class=
"Apple-converted-space"> </span></p>
144 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>y.indexOfGreaterThan(
70);
<span class=
"Apple-converted-space"> </span></p>
145 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
146 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>find(sublist, offset)
</b></p>
147 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>If the
<b>sublist
</b> exists in the receiver (in the specified order), at an offset greater than or equal to the initial
<b>offset
</b>, then return the starting index.
</p>
148 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
149 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>y = [
7,
8,
7,
6,
5,
6,
7,
6,
7,
8,
9]
</p>
150 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>y.find([
7,
6,
5]);
</p>
151 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
152 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>findAll(arr, offset)
</b></p>
153 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Similar to
<b>find()
</b> but returns an array of all the indices at which the sequence is found.
</p>
154 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
155 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>y = [
7,
8,
7,
6,
5,
6,
7,
6,
7,
8,
9]
</p>
156 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>y.findAll([
7,
6]);
</p>
157 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
158 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>indexIn(val)
</b></p>
159 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>returns the closest index of the value in the collection (collection must be sorted)
</p>
160 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
161 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>[
2,
3,
5,
6].indexIn(
5.2)
</p>
162 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
163 <p class=
"p6"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span><b>indexInBetween(val)
</b></p>
164 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>returns a linearly interpolated float index for the value (collection must be sorted)
</p>
165 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>inverse operation is
<b>blendAt
</b></p>
166 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
167 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>x = [
2,
3,
5,
6].indexInBetween(
5.2)
</p>
168 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>[
2,
3,
5,
6].blendAt(x)
</p>
169 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
170 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
171 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>blendAt(floatIndex)
</b></p>
172 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>returns a linearly interpolated value between the two closest indices
</p>
173 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>inverse operation is
<b>indexInBetween
</b></p>
174 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span><b><span class=
"Apple-tab-span"> </span></b></span>x = [
2,
5,
6].blendAt(
0.4)
</p>
175 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
176 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
177 <p class=
"p6"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span><b>copyRange(start, end)
</b></p>
178 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Return a new SequenceableCollection which is a copy of the indexed slots of the receiver from
<b>start
</b> to
<b>end
</b>.
</p>
179 <p class=
"p6"><span class=
"Apple-tab-span"> </span>x.copyRange(a, b) can also be written as
<b>x[a..b]
</b></p>
180 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
181 <p class=
"p7"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span>(
</p>
182 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"s2">var
</span> y, z;
</p>
183 <p class=
"p7"><span class=
"Apple-tab-span"> </span>z = [
1,
2,
3,
4,
5];
</p>
184 <p class=
"p7"><span class=
"Apple-tab-span"> </span>y = z.copyRange(
1,
3);
</p>
185 <p class=
"p7"><span class=
"Apple-tab-span"> </span>z.postln;
</p>
186 <p class=
"p7"><span class=
"Apple-tab-span"> </span>y.postln;
</p>
187 <p class=
"p7"><span class=
"Apple-tab-span"> </span>)
</p>
188 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
189 <p class=
"p6"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span><b>copyToEnd(start)
</b></p>
190 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Return a new SequenceableCollection which is a copy of the indexed slots of the receiver from
<b>start
</b> to the end of the collection. x.copyToEnd(a) can also be written as
<b>x[a..]
</b></p>
191 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
192 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>copyFromStart(end)
</b></p>
193 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Return a new SequenceableCollection which is a copy of the indexed slots of the receiver from the start of the collection to
<b>end
</b>. x.copyFromStart(a) can also be written as
<b>x[..a]
</b></p>
194 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
195 <p class=
"p6"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span><b>remove(item)
</b></p>
196 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Remove
<b>item
</b> from collection.
</p>
197 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
198 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>take(item)
</b></p>
199 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Remove and return
<b>item
</b> 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
<a href=
"ArrayedCollection.html"><span class=
"s2">ArrayedCollection
</span></a>.
</p>
200 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
201 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>a = [
11,
12,
13,
14,
15];
</p>
202 <p class=
"p7"><span class=
"Apple-tab-span"> </span>a.take(
12);
</p>
203 <p class=
"p7"><span class=
"Apple-tab-span"> </span>a
</p>
204 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
205 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>keep(n)
</b></p>
206 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Keep the first
<b>n
</b> items of the array. If
<b>n
</b> is negative, keep the last –
<b>n
</b> items.
</p>
207 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
208 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>a = [
1,
2,
3,
4,
5];
</p>
209 <p class=
"p7"><span class=
"Apple-tab-span"> </span>a.keep(
3);
</p>
210 <p class=
"p7"><span class=
"Apple-tab-span"> </span>a.keep(-
3);
</p>
211 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
212 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>drop(n)
</b></p>
213 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Drop the first
<b>n
</b> items of the array. If
<b>n
</b> is negative, drop the last –
<b>n
</b> items.
</p>
214 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
215 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>a = [
1,
2,
3,
4,
5];
</p>
216 <p class=
"p7"><span class=
"Apple-tab-span"> </span>a.drop(
3);
</p>
217 <p class=
"p7"><span class=
"Apple-tab-span"> </span>a.drop(-
3);
</p>
218 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
219 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>join(joiner)
</b></p>
220 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Returns a
<a href=
"String.html"><span class=
"s2">String
</span></a> formed by connecting all the elements of the receiver, with
<b>joiner
</b> imbetween.
</p>
221 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
222 <p class=
"p12"><span class=
"s8"><span class=
"Apple-tab-span"> </span></span><span class=
"s6">[
</span>"m"<span class=
"s6">,
</span>"ss"<span class=
"s6">,
</span>"ss"<span class=
"s6">,
</span>"pp"<span class=
"s6">,
</span>""<span class=
"s6">].join(
</span>"i"<span class=
"s6">)
</span></p>
223 <p class=
"p13"><span class=
"Apple-tab-span"> </span></p>
224 <p class=
"p6"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span><b>flat
</b></p>
225 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Returns a collection from which all nesting has been flattened.
</p>
226 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
227 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>[[
1,
2,
3], [[
4,
5], [[
6]]]].flat;
</p>
228 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
229 <p class=
"p6"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span><b>flatten(numLevels)
</b></p>
230 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Returns a collection from which numLevels of nesting has been flattened.
</p>
231 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
232 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>[[
1,
2,
3], [[
4,
5], [[
6]]]].flatten(
1).postcs;
</p>
233 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
234 <p class=
"p7"><span class=
"Apple-tab-span"> </span>[[
1,
2,
3], [[
4,
5], [[
6]]]].flatten(
2).postcs;
</p>
235 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
236 <p class=
"p6"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span><b>flop
</b></p>
237 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Invert rows and colums in a two dimensional Collection (turn inside out).
</p>
238 <p class=
"p6"><span class=
"Apple-tab-span"> </span>See also:
<a href=
"../Core/Kernel/Function.html"><span class=
"s2">Function
</span></a>.
</p>
239 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
240 <p class=
"p7"><span class=
"Apple-tab-span"> </span>[[
1,
2,
3], [
4,
5,
6]].flop;
</p>
241 <p class=
"p7"><span class=
"Apple-tab-span"> </span>[[
1,
2,
3], [
4,
5,
6], [
7,
8]].flop;
<span class=
"s10">// shorter array wraps
</span></p>
242 <p class=
"p14"><span class=
"s6"><span class=
"Apple-tab-span"> </span>[].flop;
</span>// result is always
2-d.
</p>
243 <p class=
"p15"><span class=
"Apple-tab-span"> </span></p>
244 <p class=
"p6"><span class=
"s11"><span class=
"Apple-tab-span"> </span></span><b>flopTogether(...moreArrays)
</b></p>
245 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Invert rows and colums in a an array of dimensional Collections (turn inside out), so that they
<span class=
"Apple-converted-space"> </span></p>
246 <p class=
"p6"><span class=
"Apple-tab-span"> </span>all match up in size, but remain separated.
</p>
247 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
248 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
249 <p class=
"p7"><span class=
"Apple-tab-span"> </span>(
</p>
250 <p class=
"p7"><span class=
"Apple-tab-span"> </span>a = flopTogether(
</p>
251 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>[[
1,
2,
3], [
4,
5,
6,
7,
8]] *
100,
</p>
252 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>[[
1,
2,
3], [
4,
5,
6], [
7,
8]],
</p>
253 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>[
1000]
</p>
254 <p class=
"p7"><span class=
"Apple-tab-span"> </span>)
</p>
255 <p class=
"p7"><span class=
"Apple-tab-span"> </span>);
</p>
256 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
257 <p class=
"p14"><span class=
"s6"><span class=
"Apple-tab-span"> </span>a.collect(
</span><span class=
"s2">_
</span><span class=
"s6">.size);
</span>// sizes are the same
</p>
258 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"s6">a.collect(
</span><span class=
"s2">_
</span><span class=
"s6">.shape)
</span>// shapes can be different
</p>
259 <p class=
"p15"><span class=
"Apple-tab-span"> </span></p>
260 <p class=
"p15"><span class=
"Apple-tab-span"> </span></p>
261 <p class=
"p6"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span><b>lace(length)
</b></p>
262 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Returns a new Collection whose elements are interlaced sequences of the elements of the receiver's subcollections, up to size
<b>length
</b>. The receiver is unchanged.
</p>
263 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
264 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>(
</p>
265 <p class=
"p7"><span class=
"Apple-tab-span"> </span>x = [ [
1,
2,
3],
6,
<span class=
"s2">List
</span>[
<span class=
"s12">"foo"</span>,
<span class=
"s13">'bar'
</span>]];
</p>
266 <p class=
"p7"><span class=
"Apple-tab-span"> </span>y = x.lace(
12);
</p>
267 <p class=
"p7"><span class=
"Apple-tab-span"> </span>x.postln;
</p>
268 <p class=
"p7"><span class=
"Apple-tab-span"> </span>y.postln;
</p>
269 <p class=
"p7"><span class=
"Apple-tab-span"> </span>)
</p>
270 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
271 <p class=
"p6"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span><b>resamp0(newSize)
</b></p>
272 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Returns a new Collection of the desired length, with values resampled evenly-spaced from the receiver without interpolation.
</p>
273 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
274 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>[
1,
2,
3,
4].resamp0(
12);
</p>
275 <p class=
"p7"><span class=
"Apple-tab-span"> </span>[
1,
2,
3,
4].resamp0(
2);
</p>
276 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
277 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>resamp1(newSize)
</b></p>
278 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Returns a new Collection of the desired length, with values resampled evenly-spaced from the receiver with linear interpolation.
</p>
279 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
280 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>[
1,
2,
3,
4].resamp1(
12);
</p>
281 <p class=
"p7"><span class=
"Apple-tab-span"> </span>[
1,
2,
3,
4].resamp1(
3);
</p>
282 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
283 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>choose
</b></p>
284 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Choose an element from the collection at random.
</p>
285 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
286 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>[
1,
2,
3,
4].choose;
</p>
287 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
288 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>wchoose
</b></p>
289 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Choose an element from the collection at random using a list of probabilities or weights.
</p>
290 <p class=
"p6"><span class=
"Apple-tab-span"> </span>The weights must sum to
1.0.
</p>
291 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
292 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>[
1,
2,
3,
4].wchoose([
0.1,
0.2,
0.3,
0.4]);
</p>
293 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
294 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>sort(function)
</b></p>
295 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Sort the contents of the collection using the comparison function argument.
</p>
296 <p class=
"p6"><span class=
"Apple-tab-span"> </span>The function should take two elements as arguments and return true if the first
</p>
297 <p class=
"p6"><span class=
"Apple-tab-span"> </span>argument should be sorted before the second argument.
</p>
298 <p class=
"p6"><span class=
"Apple-tab-span"> </span>If the function is nil, the following default function is used.
</p>
299 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
300 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>{
<span class=
"s2">arg
</span> a, b; a
< b }
</p>
301 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
302 <p class=
"p16"><span class=
"Apple-tab-span"> </span></p>
303 <p class=
"p7"><span class=
"s14"><span class=
"Apple-tab-span"> </span></span>[
6,
2,
1,
7,
5].sort;
</p>
304 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
305 <p class=
"p7"><span class=
"Apple-tab-span"> </span>[
6,
2,
1,
7,
5].sort({
<span class=
"s2">arg
</span> a, b; a
> b });
<span class=
"s10">// reverse sort
</span></p>
306 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
307 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
308 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>sortBy(key)
</b></p>
309 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Sort the contents of the collection using the key
<b>key
</b>, which is assumed to be found inside each element of the receiver.
</p>
310 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
311 <p class=
"p7"><span class=
"s15"><span class=
"Apple-tab-span"> </span></span>(
</p>
312 <p class=
"p7"><span class=
"Apple-tab-span"> </span>a = [
</p>
313 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">Dictionary
</span>[
<span class=
"s13">\a
</span>-
>5,
<span class=
"s13">\b
</span>-
>1,
<span class=
"s13">\c
</span>-
>62],
<span class=
"Apple-converted-space"> </span></p>
314 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">Dictionary
</span>[
<span class=
"s13">\a
</span>-
>2,
<span class=
"s13">\b
</span>-
>9,
<span class=
"s13">\c
</span>-
>65],
<span class=
"Apple-converted-space"> </span></p>
315 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">Dictionary
</span>[
<span class=
"s13">\a
</span>-
>8,
<span class=
"s13">\b
</span>-
>5,
<span class=
"s13">\c
</span>-
>68],
<span class=
"Apple-converted-space"> </span></p>
316 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">Dictionary
</span>[
<span class=
"s13">\a
</span>-
>1,
<span class=
"s13">\b
</span>-
>3,
<span class=
"s13">\c
</span>-
>61],
<span class=
"Apple-converted-space"> </span></p>
317 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">Dictionary
</span>[
<span class=
"s13">\a
</span>-
>6,
<span class=
"s13">\b
</span>-
>7,
<span class=
"s13">\c
</span>-
>63],
<span class=
"Apple-converted-space"> </span></p>
318 <p class=
"p7"><span class=
"Apple-tab-span"> </span>]
</p>
319 <p class=
"p7"><span class=
"Apple-tab-span"> </span>)
</p>
320 <p class=
"p7"><span class=
"Apple-tab-span"> </span>a.sortBy(
<span class=
"s13">\b
</span>);
</p>
321 <p class=
"p7"><span class=
"Apple-tab-span"> </span>a.sortBy(
<span class=
"s13">\c
</span>);
</p>
322 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
323 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
324 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>order(function)
</b></p>
325 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Return an array of indices that would sort the collection into order.
<b>function
</b> is treated the same way as for the
<b>sort
</b> method.
</p>
326 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
327 <p class=
"p16"><span class=
"Apple-tab-span"> </span></p>
328 <p class=
"p7"><span class=
"s14"><span class=
"Apple-tab-span"> </span></span>[
6,
2,
1,
7,
5].order;
</p>
329 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
330 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
331 <p class=
"p6"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span><b>swap(i, j)
</b></p>
332 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Swap two elements in the collection at indices i and j.
</p>
333 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
334 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>pairsDo(function)
</b></p>
335 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Calls function for each subsequent pair of elements in the SequentialCollection.
</p>
336 <p class=
"p6"><span class=
"Apple-tab-span"> </span>The function is passed the two elements and an index.
</p>
337 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
338 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>[
1,
2,
3,
4,
5].pairsDo({
<span class=
"s2">arg
</span> a, b; [a, b].postln; });
</p>
339 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
340 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>doAdjacentPairs(function)
</b></p>
341 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Calls function for every adjacent pair of elements in the SequentialCollection.
</p>
342 <p class=
"p6"><span class=
"Apple-tab-span"> </span>The function is passed the two adjacent elements and an index.
</p>
343 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
344 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>[
1,
2,
3,
4,
5].doAdjacentPairs({
<span class=
"s2">arg
</span> a, b; [a, b].postln; });
</p>
345 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
346 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>separate(function)
</b></p>
347 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Separates the collection into sub-collections by calling the function for each adjacent pair of elements.
</p>
348 <p class=
"p6"><span class=
"Apple-tab-span"> </span>If the function returns true, then a separation is made between the elements.
</p>
349 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
350 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span> [
1,
2,
3,
5,
6,
8,
10].separate({
<span class=
"s2">arg
</span> a, b; (b - a)
> 1 }).postcs;
</p>
351 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
352 <p class=
"p6"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span><b>clump(groupSize)
</b></p>
353 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Separates the collection into sub-collections by separating every groupSize elements.
</p>
354 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
355 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>[
1,
2,
3,
4,
5,
6,
7,
8].clump(
3).postcs;
</p>
356 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
357 <p class=
"p6"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span><b>clumps(groupSizeList)
</b></p>
358 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Separates the collection into sub-collections by separating elements into groupings whose size
</p>
359 <p class=
"p6"><span class=
"Apple-tab-span"> </span>is given by integers in the groupSizeList.
</p>
360 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
361 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>[
1,
2,
3,
4,
5,
6,
7,
8].clumps([
1,
2]).postcs;
</p>
362 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
363 <p class=
"p6"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span><b>curdle(probability)
</b></p>
364 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Separates the collection into sub-collections by separating elements according to the
</p>
365 <p class=
"p6"><span class=
"Apple-tab-span"> </span>given probability.
</p>
366 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
367 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>[
1,
2,
3,
4,
5,
6,
7,
8].curdle(
0.3).postcs;
</p>
368 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
369 <p class=
"p6"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span><b>integrate
</b></p>
370 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Returns a collection with the incremental sums of all elements
</p>
371 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
372 <p class=
"p7"><span class=
"Apple-tab-span"> </span>[
3,
4,
1,
1].integrate;
</p>
373 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
374 <p class=
"p6"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span><b>differentiate
</b></p>
375 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Returns a collection with the pairwise difference between all elements
</p>
376 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
377 <p class=
"p7"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span>[
3,
4,
1,
1].differentiate;
</p>
378 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
379 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>reduce(operator)
</b></p>
380 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Applies the method named by operator to the first and second elements of the collection - 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. operator may be a
<a href=
"../Core/Kernel/Function.html"><span class=
"s2">Function
</span></a> or a
<a href=
"../Core/Symbol.html"><span class=
"s2">Symbol
</span></a>.
</p>
381 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
382 <p class=
"p14"><span class=
"s8"><span class=
"Apple-tab-span"> </span></span><span class=
"s6">[
3,
4,
5,
6].reduce(
</span><span class=
"s13">'*'
</span><span class=
"s6">);
</span>// this is the same as [
3,
4,
5,
6].product
</p>
383 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"s6">[
3,
4,
5,
6].reduce(
</span><span class=
"s13">\lcm
</span><span class=
"s6">);
</span>// Lowest common multiple of the whole set of numbers
</p>
384 <p class=
"p7"><span class=
"s10"><span class=
"Apple-tab-span"> </span></span>[
<span class=
"s12">"d"</span>,
<span class=
"s12">"e"</span>, (
0.
.9),
<span class=
"s12">"h"</span>].reduce(
<span class=
"s13">'++'
</span>);
<span class=
"s10">// concatenation
</span></p>
385 <p class=
"p7"><span class=
"Apple-tab-span"> </span>[
3,
4,
5,
6].reduce({
<span class=
"s2">|a, b|
</span> sin(a) * sin(b) });
<span class=
"s10">// product of sines
</span></p>
386 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
387 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
388 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>convertDigits(base)
</b></p>
389 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Returns an integer resulting from interpreting the elements as digits to a given base (default
10).
</p>
390 <p class=
"p6"><span class=
"Apple-tab-span"> </span>See also
<b>asDigits
</b> in
<a href=
"../Math/Integer.html"><span class=
"s2">Integer
</span></a> for the complementary method.
</p>
391 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
392 <p class=
"p7"><span class=
"Apple-tab-span"> </span>[
1,
0,
0,
0].convertDigits;
</p>
393 <p class=
"p7"><span class=
"Apple-tab-span"> </span>[
1,
0,
0,
0].convertDigits(
2);
</p>
394 <p class=
"p7"><span class=
"Apple-tab-span"> </span>[
1,
0,
0,
0].convertDigits(
3);
</p>
395 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
396 <p class=
"p6"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span><b>hammingDistance(that)
</b></p>
397 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Returns the count of array elements that are not equal in identical positions.
<span class=
"s16">http://en.wikipedia.org/wiki/Hamming_distance
</span></p>
398 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
399 <p class=
"p6"><span class=
"Apple-tab-span"> </span>The collections are not wrapped - if one array is shorter than the other, the difference in size should be included in the count.
</p>
400 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
401 <p class=
"p7"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span>[
0,
0,
0,
1,
1,
1,
0,
1,
0,
0].hammingDistance([
0,
0,
1,
1,
0,
0,
0,
0,
1,
1])
</p>
402 <p class=
"p12"><span class=
"s6"><span class=
"Apple-tab-span"> </span></span>"SuperMan"<span class=
"s6">.hammingDistance(
</span>"SuperCollider"<span class=
"s6">);
</span></p>
403 <p class=
"p13"><span class=
"Apple-tab-span"> </span></p>
404 <p class=
"p17"><br></p>
405 <p class=
"p17"><br></p>
406 <p class=
"p18"><b>Math Support
</b></p>
407 <p class=
"p2"><br></p>
408 <p class=
"p18"><b>Unary Messages:
</b></p>
409 <p class=
"p2"><br></p>
410 <p class=
"p1">All of the following messages send the message performUnaryOp to the receiver with the
</p>
411 <p class=
"p1">unary message selector as an argument.
</p>
412 <p class=
"p2"><br></p>
413 <p class=
"p1"><b>neg, reciprocal, bitNot, abs, asFloat, asInt, ceil, floor, frac, sign, squared, cubed, sqrt
</b></p>
414 <p class=
"p1"><b>exp, midicps, cpsmidi, midiratio, ratiomidi, ampdb, dbamp, octcps, cpsoct, log, log2,
<span class=
"Apple-converted-space"> </span></b></p>
415 <p class=
"p1"><b>log10, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, rand, rand2, linrand, bilinrand,
<span class=
"Apple-converted-space"> </span></b></p>
416 <p class=
"p1"><b>sum3rand, distort, softclip, nyqring, coin, even, odd, isPositive, isNegative,
<span class=
"Apple-converted-space"> </span></b></p>
417 <p class=
"p1"><b>isStrictlyPositive, real, imag, magnitude, magnitudeApx, phase, angle, rho, theta,
<span class=
"Apple-converted-space"> </span></b></p>
418 <p class=
"p1"><b>asFloat, asInteger
</b></p>
419 <p class=
"p2"><br></p>
420 <p class=
"p6"><b>performUnaryOp(aSelector)
</b></p>
421 <p class=
"p6"><span class=
"Apple-tab-span"> </span>Creates a new collection of the results of applying the selector to all elements in the receiver.
</p>
422 <p class=
"p9"><br></p>
423 <p class=
"p7"><span class=
"Apple-tab-span"> </span>[
1,
2,
3,
4].neg;
</p>
424 <p class=
"p8"><br></p>
425 <p class=
"p7"><span class=
"Apple-tab-span"> </span>[
1,
2,
3,
4].reciprocal;
</p>
426 <p class=
"p19"><br></p>
427 <p class=
"p18"><b>Binary Messages:
</b></p>
428 <p class=
"p20"><br></p>
429 <p class=
"p1">All of the following messages send the message performBinaryOp to the receiver with the
</p>
430 <p class=
"p1">binary message selector and the second operand as arguments.
</p>
431 <p class=
"p2"><br></p>
432 <p class=
"p1"><b>+, -, *, /, div, %, **, min, max,
<,
<=,
>,
>=,
&, |, bitXor, lcm, gcd, round, trunc, atan2,
<span class=
"Apple-converted-space"> </span></b></p>
433 <p class=
"p1"><b>hypot,
>>, +
>>, fill, ring1, ring2, ring3, ring4, difsqr, sumsqr, sqrdif, absdif, amclip,
<span class=
"Apple-converted-space"> </span></b></p>
434 <p class=
"p1"><b>scaleneg, clip2, excess,
<!, rrand, exprand
</b></p>
435 <p class=
"p2"><br></p>
436 <p class=
"p6"><b>performBinaryOp(aSelector, theOperand)
</b></p>
437 <p class=
"p6"><span class=
"Apple-tab-span"> </span>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.
</p>
438 <p class=
"p5"><br></p>
439 <p class=
"p7"><span class=
"Apple-tab-span"> </span>([
1,
2,
3,
4] *
10);
</p>
440 <p class=
"p8"><br></p>
441 <p class=
"p7"><span class=
"Apple-tab-span"> </span>([
1,
2,
3,
4] * [
4,
5,
6,
7]);
</p>
442 <p class=
"p9"><br></p>
443 <p class=
"p5"><br></p>