Returns a FoscTypedList.
A typed list.
| concat | Concatenates typed list and expr. |
| add | Appends item to list. |
| append | – REMOVE |
| addAll | |
| extend | – REMOVE |
| insert | Inserts item at index. |
| pop | Puts item at index. |
| prepend | Prepends item to list. |
| put | Puts item at index. |
| remove | Remove item. |
| removeAt | Remove item at index. |
| sort |
| at | Gets item at index. |
| atAll | Gets items at indices. |
| includes | Answer true if item exists in collection. |
| indexOf | (abjad: index) |
| occurrencesOf | (abjad: count) |
| collect | |
| reject | |
| select |
| inspect | Inspect items in collection. |
Example
x = FoscTypedList([1, 2, 3, 4], Number);
x.inspect;FoscTypedList([
1,
2,
3,
4
])Concatenates typed list and expr.
Returns new typed list.
FIXME ERROR: Message asList not understood.
a = FoscTypedList([1, 2, 3, 4], Number);
b = FoscTypedList([5, 6], Number);
(a ++ b).inspect;Appends item to list.
Example
a = FoscTypedList([1, 2, 3, 4], Number);
a.add(5);
a.inspect;FoscTypedList([
1,
2,
3,
4,
5
])– REMOVE
Example
a = FoscTypedList([1, 2, 3, 4], Number);
a.extend([5, 6, 7]);
a.inspect;FoscTypedList([
1,
2,
3,
4,
5,
6,
7
])– REMOVE
Inserts item at index.
Puts item at index.
Example
a = FoscTypedList([1, 2, 3, 4], Number);
a.pop;
a.inspect;FoscTypedList([
1,
2,
3
])Prepends item to list.
Example
a = FoscTypedList([1, 2, 3, 4], Number);
a.prepend(5);
a.inspect;FoscTypedList([
5,
1,
2,
3,
4
])Puts item at index.
Example
a = FoscTypedList([1, 2, 3, 4], Number);
a[1] = 5;
a.inspect;FoscTypedList([
1,
5,
3,
4
])Remove item.
Example
a = FoscTypedList([1, 2, 3, 4], Number);
a.remove(3);
a.inspect;FoscTypedList([
1,
2,
4
])Remove item at index.
Example
a = FoscTypedList([1, 2, 3, 4], Number);
a.removeAt(1);
a.inspect;FoscTypedList([
1,
3,
4
])Example
a = FoscTypedList([5, 2, 3, 4], Number);
a.sort;
a.inspect;FoscTypedList([
2,
3,
4,
5
])
a = FoscTypedList([5, 2, 3, 4], Number);
a.sort { |a, b| a > b };
a.inspect;FoscTypedList([
5,
4,
3,
2
])Gets item at index.
Returns item.
Example
a = FoscTypedList([1, 2, 3, 4], Number);
a[2];3Gets items at indices.
Returns items.
Example
a = FoscTypedList([1, 2, 3, 4], Number);
a[(2..3)];[ 3, 4 ]Answer true if item exists in collection.
Returns boolean.
Example
a = FoscTypedList([1, 2, 3, 4], Number);
a.includes(3);
a.includes(5);false(abjad: index)
Return the first index matching item.
Returns nonegative integer.
Example
a = FoscTypedList([1, 2, 3, 4], Number);
a.indexOf(3);2(abjad: count)
Return the number of occurrences of item in collection.
Returns nonegative integer.
Example
a = FoscTypedList([1, 2, 3, 4], Number);
a.occurrencesOf(3);1Example
x = FoscTypedList([1, 2, 3, 4], Number);
x = x.collect { |each| each * 2 };
x.inspect;FoscTypedList([
2,
4,
6,
8
])Example
x = FoscTypedSequenceableCollection([1, 2, 3, 4], Number);
x = x.reject { |each| each.even };
x.inspect;FoscTypedSequenceableCollection([
1,
3
])Example
x = FoscTypedSequenceableCollection([1, 2, 3, 4], Number);
x = x.select { |each| each.even };
x.inspect;FoscTypedSequenceableCollection([
2,
4
])Inspect items in collection.
Example
a = FoscTypedList([1, 2, 3, 4], Number);
a.inspect;FoscTypedList([
1,
2,
3,
4
])