Returns a FoscTypedCollection.
A typed collection.
| == | |
| != | |
| asCompileString | |
| difference | Set-theoretic difference of receiver and expr. |
| sect | Set-theoretic intersection of receiver and expr. |
| isDisjoint | Is true when typed receiver shares no elements with expr. Otherwise false. |
| isEmpty | Is true when set is empty. |
| isSubsetOf | Is true when receiver is a subset of expr. Otherwise false. |
| isSupersetOf | Is true when receiver is a superset of expr. Otherwise false. |
| notEmpty | Is true when set is not empty. |
| symmetricDifference | Symmetric difference of receiver and expr. |
| union | Union of receiver and expr. |
| do | |
| iter |
| includes | |
| indexOf | |
| isCollection | |
| items | |
| size | Size of typed collection. |
| inspect |
Example
x = FoscTypedCollection([1, 2, 3, 4], Number);FoscTypedCollection([
1,
2,
3,
4
])
x = FoscTypedCollection([1, 2, 3, 4, 'x'], Number);ERROR: Meta_FoscTypedCollection:new: item x is the wrong type: Symbol.Example
a = FoscTypedCollection([1, 2, 3, 4], Number);
b = FoscTypedCollection([1, 2], Number);
a == b;false
a == a.copy;trueExample
a = FoscTypedCollection([1, 2, 3, 4], Number);
b = FoscTypedCollection([1, 2], Number);
a != b;true
a != a.copy;falseExample
t = FoscTimespanList([
FoscTimespan(0, 10),
FoscTimespan(10, 20),
FoscTimespan(30, 40)
]);
t.cs;FoscTimespanList([
FoscTimespan(0/1, 10/1),
FoscTimespan(10/1, 20/1),
FoscTimespan(30/1, 40/1)
])Set-theoretic difference of receiver and expr.
Returns new typed frozen set.
Example
a = FoscTypedCollection([1, 2, 3], Number);
b = FoscTypedCollection([2, 3, 4], Number);
x = a.difference(b); // x = (a - b);
x.inspect;FoscTypedCollection([
1
])Example
a = FoscPitchClassSet([1, 2, 3]);
b = FoscPitchClassSet([2, 3, 4]);
a.difference(b).items.collect { |each| each.pitchClassNumber };[ 1.0 ]Set-theoretic intersection of receiver and expr.
Returns new typed frozen set.
Example
a = FoscTypedCollection([1, 2, 3], Number);
b = FoscTypedCollection([2, 3, 4], Number);
x = sect(a, b); // x = (a & b);
x.inspect;FoscTypedCollection([
2,
3
])Example
a = FoscPitchClassSet([1, 2, 3]);
b = FoscPitchClassSet([2, 3, 4]);
a.sect(b).items.collect { |each| each.pitchClassNumber };[ 2.0, 3.0 ]Is true when typed receiver shares no elements with expr. Otherwise false.
Returns boolean.
Example
a = FoscTypedCollection([1, 2, 3], Number);
b = FoscTypedCollection([4], Number);
c = FoscTypedCollection([3, 4], Number);
isDisjoint(a, b);true
isDisjoint(a, c);falseIs true when set is empty.
Returns boolean.
Example
a = FoscTypedCollection([1, 2, 3], Number);
a.isEmpty;false
a = FoscTypedCollection([], Number);
a.isEmpty;trueIs true when receiver is a subset of expr. Otherwise false.
Returns boolean.
Example
a = FoscTypedCollection([1, 2, 3], Number);
b = FoscTypedCollection([4], Number);
c = FoscTypedCollection([1, 2, 3, 4], Number);
b.isSubsetOf(a);false
a.isSubsetOf(c);true
a = FoscPitchClassSet([1, 2, 3]);
b = FoscPitchClassSet([2, 3]);
a.isSubsetOf(b);false
b.isSubsetOf(a);trueIs true when receiver is a superset of expr. Otherwise false.
Returns boolean.
Example
a = FoscTypedCollection([1, 2, 3], Number);
b = FoscTypedCollection([4], Number);
c = FoscTypedCollection([1, 2, 3, 4], Number);
b.isSupersetOf(a);false
c.isSupersetOf(a);true
a = FoscPitchClassSet([1, 2, 3]);
b = FoscPitchClassSet([2, 3]);
a.isSupersetOf(b);true
b.isSupersetOf(a);falseIs true when set is not empty.
Returns boolean.
Example
a = FoscTypedCollection([1, 2, 3], Number);
a.notEmpty;true
a = FoscTypedCollection([], Number);
a.notEmpty;falseSymmetric difference of receiver and expr.
Returns new typed frozen set.
Example
a = FoscTypedCollection([1, 2, 3], Number);
b = FoscTypedCollection([2, 3, 4], Number);
x = symmetricDifference(a, b); // a -- b;
x.inspect;FoscTypedCollection([
1,
4
])
a = FoscPitchClassSet([1, 2, 3]);
b = FoscPitchClassSet([2, 3, 4]);
a.symmetricDifference(b).items.collect { |each| each.pitchClassNumber };[ 1.0, 4.0 ]Union of receiver and expr.
Returns new typed frozen set.
Example
a = FoscTypedCollection([1, 2, 3], Number);
b = FoscTypedCollection([2, 3, 4], Number);
x = union(a, b); // x = (a | b);
x.inspect;FoscTypedCollection([
1,
2,
3,
4
])
a = FoscPitchClassSet([1, 2, 3]);
b = FoscPitchClassSet([2, 3, 4]);
a.union(b).items.collect { |each| each.pitchClassNumber };[ 1.0, 2.0, 3.0, 4.0 ]Example
x = FoscTypedCollection([1, 2, 3, 4], Number);
x.do { |each| (each * 2).postln };[ 1, 2, 3, 4 ]Example
a = FoscTypedCollection([1, 2, 3, 4], Number);
a = a.iter;
5.do { a.next.postln };5Example
a = FoscTypedCollection([1, 2, 3, 4], Number);
a.includes(4);trueExample
a = FoscTypedCollection([1, 2, 3, 4], Number);
a.indexOf(3);2
a = FoscTypedCollection([1, 2, 3, 4].collect { |each| FoscPitchClass(each) }, FoscPitchClass);
a.indexOf(3);2Example
a = FoscTypedCollection([1, 2, 3, 4], Number);
a.isCollection;trueExample
x = FoscTypedCollection([1, 2, 3, 4], Number);
x.items;[ 1, 2, 3, 4 ]Size of typed collection.
Returns nonnegative integer.
Example
a = FoscTypedCollection([1, 2, 3, 4], Number);
a.size;4