-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathArray-ext.sc
99 lines (61 loc) · 1.36 KB
/
Array-ext.sc
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
+ Array {
/*
* method for substitution of a
* Number with a Structure
* inside a Structure:
*
* a = [3, 2, 1, 2, 1]
* a.subst(3, [2, 1, 2]) // ==> [ 3, 2, 1, [ 2, [ 2, 1, 2 ] ], 1 ]
*
* This actually is a subdivision of a element in our score representation
*
*/
subst { arg index, thisStruct;
case
{thisStruct.isKindOf(Array)}
{^this.put(index, [this.at(index), thisStruct])}
{thisStruct.isKindOf(Number)}
{^this.put(index, thisStruct)};
}
gdc {
if(this.containsSeqColl.not, {
^this.reduce({arg a, b; a.asInteger gcd: b.asInteger})
});
}
minimum{
if(this.containsSeqColl.not, {
^this.reduce({arg a, b; a max: b})
});
}
minimum {
if(this.containsSeqColl.not, {
^this.reduce({arg a, b; a min: b})
});
}
minSize {
^(this.collect {|i| i.size}).minimum
}
maxSize {
^(this.collect {|i| i.size}).minimum
}
asRhythmicCell {
^RhythmicCell(this)
}
asRC {
^RhythmicCell(this)
}
asRhythmicSeq {
^RhythmicSeq(this)
}
asRS {
^RhythmicSeq(this)
}
addRC { arg thisRSeq;
thisRSeq.put(this)
}
addRS { arg thisRSeq;
this.do { |i|
thisRSeq.put(i)
};
}
}