-
Notifications
You must be signed in to change notification settings - Fork 0
Query Functions
Same as Where in LINQ to Objects.
-
where(bool predicate(T))
Filters elements based on the predicate.
predicate is called with each element and returns false if the element should be filtered.Enumerable.from([10,20,30]).where("_ <= 20"); // => 10, 20
-
where(bool predicate(T, int))
predicate can take an index as 2nd argument. -
where(bool predicate(T, int, args*), args*)
All arguments are passed to predicate.
Same as Distinct in LINQ to Objects.
-
distinct()
Removes all duplicated elements.Enumerable.from([1,1,2.0,2,3]).distinct(); // => 1,2.0,3
-
distinct(String keySelector(T))
keySelector is called with each element and returns string which is used to compare elements.Enumerable.from([0,1,2,3,4,5]).distinct("_ % 3"); // => 0,1,2
-
distinct(String keySelector(T, args*), args*)
All arguments are passed to keySelector.
Same as Skip in LINQ to Objects.
-
skip(int count)
Skips the specified number of elements.Enumerable.from([1,2,3,4]).skip(2); // => 3,4
Same as SkipWhile in LINQ to Objects.
-
skipWhile(bool predicate(T))
Skips elements while predicate returns true.
predicate is called with each element and return true if the element should be skipped.Enumerable.from([1,2,3,4]).skipWhile("_ != 3"); // => 3,4
-
skipWhile(bool predicate(T, int))
predicate can take an index as 2nd argument. -
skipWhile(bool predicate(T, int, args*), args*)
All arguments are passed to predicate.
Same as Take in LINQ to Objects.
-
take(int count)
Takes the specified number of elements. The left elements are ignored.Enumerable.from([1,2,3,4]).take(2); // => 1,2
Same as TakeWhile in LINQ to Objects.
-
takeWhile(bool predicate(T))
Takes elements while predicate returns true.
predicate is called with each element and returns true if the element should be taken.Enumerable.from([1,2,3,4]).takeWhile("_ != 3"); // => 1, 2
-
takeWhile(bool predicate(T, int))
predicate can take an index as 2nd argument. -
takeWhile(bool predicate(T, int, args*), args*)
All arguments are passed to predicate.
Same as Select in LINQ to Objects.
-
select(T2 selector(T))
Transforms each element.
selector is called with each element and returns a transformed element.Enumerable.from([10,20,30]).select("_ * 2"); // => 20, 40, 60
-
select(T2 selector(T, int))
selector can take an index as 2nd argument. -
select(T2 selector(T, int, args*), args*)
All arguments are passed to selector.
Same as SelectMany in LINQ to Objects.
-
selectMany(TCollection[] collectionSelector(T))
Flattens each sequences which collectionSelector returns.
collectionSelector is called with each element and returns sequence which will be flattened.Enumerable.from([[10,20,30], [1,2]]).selectMany("_"); // => 10, 20, 30, 1, 2
-
selectMany(TCollection[] collectionSelector(T, int))
collectionSelector can take an index as 2nd argument. -
selectMany(TCollection[] collectionSelector(T), TResult resultSelector(T, TCollection))
resultSelector is called with each element of the sequence which collectionSelector returns.
Its 1st argument is the same as collectionSelector's argument and 2nd argument is each element.Enumerable.from([ %[ name:"even", data:[2,4] ], %[ name:"odd", data:[3,5,7] ] ]).selectMany("_.data", "_.name + ':' + _2"); // => "even:2", "even:4", "odd:3", "odd:5", "odd:7"
-
selectMany(TCollection[] collectionSelector(T, int), TResult resultSelector(T, TCollection))
collectionSelector can take an index as 2nd argument. -
selectMany(TCollection[] collectionSelector(T, int, args*), TResult resultSelector(T, TCollection, args*), args*)
All arguments are passed to collectionSelector and resultSelector.
Same as Scan in Interactive Extensions.
-
scan(T accumulator(T, T))
Accumulates elements while returning processing values.
accumulator is called with accumulated value and each element and returns next accumulated value.
The first element of sequence is used as initial accumulated value.Enumerable.from("abcd").scan("_ + _2"); // => "ab", "abc", "abcd"
-
scan(T accumulator(T, T, args*), args*)
All arguments are passed to accumulator.
Same as Scan in Interactive Extensions.
-
scanWithSeed(T seed, T accumulator(T, T))
Almost the same as scan but seed can be specified.
seed is used as initial accumulated value.Enumerable.from("abcd").scanWithSeed("", "_ + _2"); // => "a", "ab", "abc", "abcd"
-
scanWithSeed(T seed, T accumulator(T, T, args*), args*)
All arguments are passed to accumulator.
Same as StartWith in Interactive Extensions.
-
startWith(values*)
Inserts specified values at the head of sequence.Enumerable.from([1,2,3]).startWith(-1,0); // => -1,0,1,2,3
Same as Concat in LINQ to Objects.
-
concat(T[] second)
Concatenates specified sequence.Enumerable.from([1,2,3]).concat([4,5]); // => 1,2,3,4,5
Same as Zip in LINQ to Objects.
-
zip(TSecond[] second, TResult resultSelector(T, TSecond))
Merges specified sequence.
resultSelector is called with two elements - former is from the source and latter is from the specified sequence as second - and returns merged new element.
If the length of two elements differ, the extra elements in longer sequence are ignored.Enumerable.from([1,2,3]).zip([4,5,6], "[_, _2]"); // => [1,4], [2,5], [3,6] Enumerable.from([1,2,3]).zip([4,5], "[_, _2]"); // => [1,4], [2,5]
-
zip(TSecond[] second, TResult resultSelector(T, TSecond, args*), args*)
All arguments are passed to resultSelector.
Same as DefaultIfEmpty in LINQ to Objects.
-
defaultIfEmpty(T defualtValue)
Only when the source is empty, inserts defaultValue.Enumerable.from([1,2,3]).defaultIfEmpty("def"); // => 1,2,3 Enumerable.empty().defaultIfEmpty("def"); // => "def"
Same as "Repeat" in Interactive Extensions.
-
repeat()
Repeats all the elements infinitely.Enumerable.from([1,2,3]).repeat(); // => 1,2,3,1,2,3,1,2,3,...
-
repeat(count)
Repeats elements specified times.Enumerable.from([1,2,3]).repeat(2); // => 1,2,3,1,2,3
Same as Join in LINQ to Objects.
-
innerJoin(T2[] inner, String outerKeySelector(T), String innerKeySelector(T2), TResult resultSelector(T, T2))
Correlates two elements from the source and the specified sequence as inner based on their keys.
inner is sequence whose elements will be correlated.
outerKeySelector is called with each element from the source and returns the corresponding key.
innerKeySelector is called with each element from inner sequence and returns the corresponding key.
resultSelector is called with two elements whose keys match and returns a result element.Enumerable.from([0,1,2]). innerJoin( Enumerable.from(["a", "b", "cd", "efg"]), "_", "_.length", "%[ length:_, str:_2 ]"); // => %[ length:1, str:"a"], %[ length:1, str:"b"], %[ length:2, str:"cd"]
-
innerJoin(T2[] inner, String outerKeySelector(T, args*), String innerKeySelector(T2, args*), TResult resultSelector(T, T2, args*), args*)
All arguments are passed to outerKeySelector, innerKeySelector, and resultSelector.
Alias of groupJoin.
Same as GroupJoin in LINQ to Objects.
-
groupJoin(T2[] inner, String outerKeySelector(T), String innerKeySelector(T2), TResult resultSelector(T, T2[]))
Correlates the element from the source and corresponding elements from the specified sequence as inner based on their keys.
inner is sequence whose elements will be correlated.
outerKeySelector is called with each element from the source and returns the corresponding key.
innerKeySelector is called with each element from inner sequence and returns the corresponding key.
resultSelector is called with a element from the source and a sequence of all matching elements from inner.
resultSelector's 2nd argument may be empty sequence. resultSelector returns a result element.Enumerable.from([0,1,2]). groupJoin( Enumerable.from(["a", "b", "cd", "efg"]), "_", "_.length", "%[ length:_, str:_2.toArray() ]"); // => %[ length:0, str:[] ], %[ length:1, str:["a","b"] ], %[ length:2, str:["cd"] ]
-
groupJoin(T2[] inner, String outerKeySelector(T, args*), String innerKeySelector(T2, args*), TResult resultSelector(T, T2[], args*), args*)
All arguments are passed to outerKeySelector, innerKeySelector, and resultSelector.
Same as GroupBy in LINQ to Objects.
-
groupBy(String keySelector(T));
Groups all the elements based on their keys.
keySelector is called with each element and returns corresponding keys.Enumerable.from([1,2,3,4,5]) .groupBy("_ % 2 == 0 ? 'odd:' : 'even:'") .select("_.key + _.toString(',')"); // => "odd:2,4", "even:1,3,5
-
groupBy(String keySelector(T), TElement elementSelector(T))
elementSelector is called with each element and returns a transformed element.Enumerable.from([1,2,3,4,5]) .groupBy("_ % 2 == 0 ? 'odd:' : 'even:'", "_ + ','") .select("_.key + _.toString()"); // => "odd:2,4", "even:1,3,5
-
groupBy(String keySelector(T), TElement elementSelector(T), TResult resultSelector(String, TElement[]))
resultSelector is called with each key returned by keySelector and sequence of matching elements returned by elementSelector.
resultSelector returns the result value.```javascript Enumerable.from([1,2,3,4,5]) .groupBy("_ % 2 == 0 ? 'odd:' : 'even:'", "_ + ','", "_ + _2.toString()") // => "odd:2,4", "even:1,3,5 ```
-
groupBy(String keySelector(T, args*), TElement elementSelector(T, args*), TResult resultSelector(String, TElement[], args*), args*)
All arguments are passed to keySelector, elementSelector, and resultSelector.
Same as Buffer in Interactive Extensions.
-
buffer(int count)
Segments the source every specified number.Enumerable.from([1,2,3,4,5]).buffer(2); // => [1,2], [3,4], [5]
-
buffer(int count, int skip)
Each segmented sequence starts after an interval of number specified as skip.
These segmented sequences can overlap.Enumerable.from([1,2,3,4,5]).buffer(2,1); // => [1,2], [2,3], [3,4], [4,5], [5]
Same as Union in LINQ to Objects.
-
union(T[] second)
Concatenates specified sequence and removes duplicated elements.Enumerable.from([1,2,3]).union([4,5,2,1]); // => 1,2,3,4,5
-
union(T[] second, String keySelector(T))
keySelector is called with each element and returns string which is used to compare elements.Enumerable.from([1,2,3]).union([0,4,5,6], "_%5"); // => 1,2,3,0,4
-
union(T[] second, String keySelector(T, args*), args*)
All arguments are passed to keySelector.
Same as Intersect in LINQ to Objects.
-
intersect(T[] second)
Creates new sequence whose elements are included in the source and the specified sequence.Enumerable.from([1,2,3]).intersect([4,5,2,3], "_%5"); // => 2,3
-
intersect(T[] second, String keySelector(T))
keySelector is called with each element and returns string which is used to compare elements.Enumerable.from([1,2,3]).intersect([0,4,5,6], "_%5"); // => 1
-
intersect(T[] second, String keySelector(T, args*), args*)
All arguments are passed to keySelector.
Same as Except in LINQ to Objects.
-
except(T[] second)
Removes elements which are included in the second and duplicated elements.Enumerable.from([1,2,3,4]).except([3,4,5,6]); // => 1,2
-
except(T[] second, String keySelector(T))
keySelector is called with each element and returns string which is used to compare elements.Enumerable.from([1,2,3]).except([0,4,5,6], "_%5"); // => 2,3
Same as OrderBy in LINQ to Objects.
-
orderBy(TKey keySelector(T))
Sorts elements in ascending order according to the selected keys.
keySelector is called with each element and returns the corresponding key.Enumerable.from([4,2,5,3,1]).orderBy("_"); // => 1,2,3,4,5
-
orderBy(TKey keySelector(T), int comparer(T, T))
comparer is called with two keys and returns -1, 0, or 1.
-1 means the 1st argument is smaller than 2nd one.
0 means the 1st and 2nd arguments are equal.
1 means the 1st argument is larger than 2nd one.
Same as OrderByDescending in LINQ to Objects.
-
orderByDescending(TKey keySelector(T))
Sorts elements in ascending order according to the selected keys.
keySelector is called with each element and returns the corresponding key.Enumerable.from([4,2,5,3,1]).orderByDescending("_"); // => 5,4,3,2,1
-
orderByDescending(TKey keySelector(T), int comparer(T, T))
comparer is called with two keys and returns -1, 0, or 1.
-1 means the 1st argument is smaller than 2nd one.
0 means the 1st and 2nd arguments are equal.
1 means the 1st argument is larger than 2nd one.
Same as ThenBy in LINQ to Objects.
-
thenBy(TKey keySelector(T))
Sorts elements in ascending order according to the selected keys subsequently to orderBy.
keySelector is called with each element and returns the corresponding key.Enumerable.from(["dd","g","","aa","f","b"]) .orderBy("_.length") .thenBy("_"); // => "","b","f","g","aa","dd"
-
thenBy(TKey keySelector(T), int comparer(T, T))
comparer is called with two keys and returns -1, 0, or 1.
-1 means the 1st argument is smaller than 2nd one.
0 means the 1st and 2nd arguments are equal.
1 means the 1st argument is larger than 2nd one.
Same as ThenByDescending in LINQ to Objects.
-
thenByDescending(TKey keySelector(T))
Sorts elements in ascending order according to the selected keys subsequently to orderBy.
keySelector is called with each element and returns the corresponding key.Enumerable.from(["dd","g","","aa","f","b"]) .orderBy("_.length") .thenByDescending("_"); // => "","g","f","b","dd","aa"
-
thenByDescending(TKey keySelector(T), int comparer(T, T))
comparer is called with two keys and returns -1, 0, or 1.
-1 means the 1st argument is smaller than 2nd one.
0 means the 1st and 2nd arguments are equal.
1 means the 1st argument is larger than 2nd one.
Same as Reverse in LINQ to Objects.
-
reverse()
Reverses the order of the elements.Enumerable.from("abcde").reverse(); // => "e","d","c","b","a"
Same as ElementAt in LINQ to Objects.
-
elementAt(int index)
Returns element at the specified index.
If the index is out of range, an exception is thrown.Enumerable.from([1,2,3,4]).elementAt(2); // => 3
Same as ElementAtOrDefault in LINQ to Objects.
-
elementAtOrDefault(int index, T defaultValue)
Returns element at the specified index.
If the index is out of range, defaultValue is returned.Enumerable.from([1,2,3,4]).elementAtOrDefault(10, 0); // => 0
Same as First in LINQ to Objects.
-
first()
Returns the first element.
If there is no element, an exception is throwns.Enumerable.from([-2,-1,0,1,2]).first(); // => -2
-
first(bool predicate(T))
Returns the first element which the predicate returns true with.
predicate is called with each element.
If no element meets the condition, an exception is thrown.Enumerable.from([-2,-1,0,1,2]).first("_ > 0"); // => 1
-
first(bool predicate(T, args*), args*)
All arguments are passed to predicate.
Same as FirstOrDefault in LINQ to Objects.
-
firstOrDefault(T defaultValue)
Returns the first element.
If there is no element, defaultValue is returned.Enumerable.from([]).firstOrDefault(1); // => 1
-
firstOrDefault(T defaultValue, bool predicate(T))
Returns the first element which the predicate returns true with.
predicate is called with each element.
If no element meets the condition, defaultValue is returned.Enumerable.from([-2,-1,0]).firstOrDefault(10, "_ > 0"); // => 10
-
firstOrDefault(T defaultValue, bool predicate(T, args*), args*)
All arguments are passed to predicate.
Same as Last in LINQ to Objects.
-
last()
Returns the last element.
If there is no element, an exception is throwns.Enumerable.from([0,1,2]).last(); // => 2
-
last(bool predicate(T))
Returns the last element which the predicate returns true with.
predicate is called with each element.
If no element meets the condition, an exception is thrown.Enumerable.from([2,1,0,-1,-2]).last("_ > 0"); // => 1
-
last(bool predicate(T, args*), args*)
All arguments are passed to predicate.
Same as LastOrDefault in LINQ to Objects.
-
lastOrDefault(T defaultValue)
Returns the last element.
If there is no element, defaultValue is returned.Enumerable.from([]).lastOrDefault(1); // => 1
-
lastOrDefault(T defaultValue, bool predicate(T))
Returns the last element which the predicate returns true with.
predicate is called with each element.
If no element meets the condition, defaultValue is returned.Enumerable.from([-2,-1,0]).lastOrDefault(10, "_ > 0"); // => 10
-
lastOrDefault(T defaultValue, bool predicate(T, args*), args*)
All arguments are passed to predicate.
Same as Single in LINQ to Objects.
-
single()
Returns the only element.
If the number of element is not one, an exception is thrown.Enumerable.from([0]).single(); // => 0
-
single(bool predicate(T))
Returns the only element which the predicate returns true with.
predicate is called with each element.
If the number of element is not one, an exception is thrown.Enumerable.from([1,0,-1]).single("_ > 0"); // => 1
-
single(bool predicate(T, args*), args*)
All arguments are passed to predicate.
Same as SingleOrDefault in LINQ to Objects.
-
singleOrDefault(T defaultValue)
Returns the only element.
If there is no element, defaultValue is returned.Enumerable.from([]).singleOrDefault(1); // => 1
-
singleOrDefault(T defaultValue, bool predicate(T))
Returns the only element which the predicate returns true with.
predicate is called with each element.
If no element meets the condition, defaultValue is returned.Enumerable.from([-2,-1,0]).singleOrDefault(10, "_ > 0"); // => 10
-
singleOrDefault(T defaultValue, bool predicate(T, args*), args*)
All arguments are passed to predicate.
Same as Count in LINQ to Objects.
-
count()
Returns the number of elements.Enumerable.from([1,2,3]).count(); // => 3
-
count(bool predicate(T))
Returns the number of elements which the *predicate returns true with.
predicate is called with each element.Enumerable.from([-1,0,1,2]).count("_ > 0"); // => 2
-
count(bool predicate(T, args*), args*)
All arguments are passed to predicate.
Same as Aggregate in LINQ to Objects.
-
aggregate(T2 accumulator(T2, T))
Accumulates elements by the specified accumulator.
The 1st argument of accumulator is the accumulated value returned by itself.
The 2nd argument is each element to accumulate.
For the first call, the first element is passed as 1st argument.
If there is no element, an exception is thrown.Enumerable.from([1,2,3,4]).aggregate("_ * _2"); // => 24
-
aggregate(T2 accumulator(T2, T), TResult resultSelector(T2))
resultSelector is called with the final accumulated value and returns a result.Enumerable.from([1,2,3,4]).aggregate("_ * _2", "_ * -1"); // => -24
-
aggregate(T2 accumulator(T2, T, args*), TResult resultSelector(T2, args*), args*)
All arguments are passed to accumulator and resultSelector.
Same as AggregateWithSeed in LINQ to Objects.
-
aggregateWithSeed(T seed, T2 accumulator(T2, T))
Accumulates elements by the specified accumulator.
The 1st argument of accumulator is the accumulated value returned by itself.
The 2nd argument is each element to accumulate.
For the first call, seed is passed as 1st argument.Enumerable.from([1,2,3,4]).aggregateWithSeed(5, "_ * _2"); // => 120
-
aggregateWithSeed(T seed, T2 accumulator(T2, T), TResult resultSelector(T2))
resultSelector is called with the final accumulated value and returns a result.Enumerable.from([1,2,3,4]).aggregateWithSeed(5, "_ * _2", "_ * -1"); // => -120
-
aggregateWithSeed(T seed, T2 accumulator(T2, T, args*), TResult resultSelector(T2, args*), args*)
All arguments are passed to accumulator and resultSelector.
Same as Average in LINQ to Objects.
-
average()
Returns the average of all elements.Enumerable.from([1,2,3,4]).average(); // => 2.5
-
average(T2 selector(T))
selector is called with each element and transforms the element.Enumerable.from(["a", "bc", "def"]).average("_.length"); // => 2
-
average(T2 selector(T, args*), args*)
All arguments are passed to selector.
Same as Max in LINQ to Objects.
-
max()
Returns the max value of all elements.Enumerable.from([1,2,3,4]).max(); // => 4
-
max(T2 selector(T))
selector is called with each element and transforms the element.Enumerable.from(["a", "bc", "def"]).max("_.length"); // => 3
-
max(T2 selector(T, args*), args*)
All arguments are passed to selector.
Same as Min in LINQ to Objects.
-
min()
Returns the max value of all elements.Enumerable.from([1,2,3,4]).min(); // => 1
-
min(T2 selector(T))
selector is called with each element and transforms the element.Enumerable.from(["a", "bc", "def"]).min("_.length"); // => 1
-
min(T2 selector(T, args*), args*)
All arguments are passed to selector.
Same as Sum in LINQ to Objects.
-
sum()
Returns the sum of all elements.Enumerable.from([1,2,3,4]).sum(); // => 10
-
sum(T2 selector(T))
selector is called with each element and transforms the element.Enumerable.from(["a", "bc", "def"]).sum("_.length"); // => 6
-
sum(T2 selector(T, args*), args*)
All arguments are passed to selector.
Same as IsEmpty in LINQ to Objects.
-
isEmpty()
Returns true if there is no element.Enumerable.from([]).isEmpty(); // => true Enumerable.from([1,2,3]).isEmpty(); // => false
Same as Any in LINQ to Objects.
-
any()
Returns true if there is no element.Enumerable.from([]).any(); // => true Enumerable.from([1,2,3]).any(); // => false
-
any(bool predicate(T))
Returns true if there is the element which the predicate returns true with.
predicate is called with each element and returns true if the element meets a condition.Enumerable.from([1,2,3]).any("_ < 0"); // => false
-
any(bool predicate(T, args*), args*)
All arguments are passed to predicate.
Same as All in LINQ to Objects.
-
all(bool predicate(T))
Returns true if predicate returns true for all elements.
predicate is called with each element and returns true if the element meets a condition.Enumerable.from([1,2,3]).all("_ > 0"); // => true Enumerable.from([1,2,3,0]).all("_ > 0"); // => false
-
all(bool predicate(T, args*), args*)
All arguments are passed to predicate.
Same as Contains in LINQ to Objects.
-
contains(T element)
Returns true if the specified elements is contained in the source.Enumerable.from([1,2,3]).contains(1); // => true Enumerable.from([1,2,3]).contains(4); // => false
-
contains(T element, bool comparer(T, T))
comparer is called with two elements and returns true if they are equal. -
contains(T element, bool comparer(T, T, args*), args*)
All arguments are passed to comparer.
Same as IndexOf in linq.js.
-
indexOf(T element)
Returns the index where the specified element is found at first.
Returns -1 if there is no elements found, returns.Enumerable.from([1,2,3]).indexOf(2); // => 1 Enumerable.from([1,2,3]).indexOf(4); // => -1
-
indexOf(T element, bool comparer(T, T))
comparer is called with two elements and returns true if they are equal. -
indexOf(T element, bool comparer(T, T, args*), args*)
All arguments are passed to comparer.
Same as SequenceEqual in LINQ to Objects.
-
sequenceEqual(T[] second)
Returns true if the source and the sequence specified as second is equal.Enumerable.from([1,2,3]).sequenceEqual([1,2,3]); // => true Enumerable.from([1,2,3]).sequenceEqual([1,2]); // => false
-
sequenceEqual(T[] second, bool comparer(T, T))
comparer is called with two elements and returns true if they are equal. -
sequenceEqual(T[] second, bool comparer(T, T, args*), args*)
All arguments are passed to comparer.
Same as ToArray in LINQ to Objects.
-
toArray()
Creates an array whose elements is contained in the source.Enumerable.from([1,2,3]).toArray(); // => [1,2,3]
Same as ToString in linq.js.
-
toString()
Creates string which concatenated all the element.Enumerable.from([1,2,3]).toString(); // => "123"
-
toString(String delimiter)
delimiter is inserted between each element.Enumerable.from([1,2,3]).toString(','); // => "1,2,3"
-
toString(String delimiter, String elementSelector(T))
elementSelector transforms each element.Enumerable.from(["a", "bc", "def"]).toString(',', "_.toUpperCase()"); // => "A,BC,DEF
-
toString(String delimiter, String elementSelector(T, args*), args*)
All arguments are passed to elementSelector.
Same as "ToDictionary" in LINQ to Objects.
-
toDictionary(String keySelector(T))
Creates dictionary whose elements are contained in the source.
keySelector is called with each element and returned the corresponding key.
If keySelector returns same key more than once, an exception is thrown.Enumerable.from([1,2]).toDictionary("_"); // => %[1:1, 2:2]
-
toDictionary(String keySelector(T), TElement elementSelector(T))
elementSelector is called with each element and returns the corresponding dictionary element.Enumerable.from(["a","bc","def"]).toDictionary("_", "_.length"); // => %[a:1, bc:2, def:3]
-
toDictionary(String keySelector(T, args*), TElement elementSelector(T, args*), args*)
All arguments are passed to keySelector and elementSelector.
Same as "ToLookup" in LINQ to Objects.
-
toLookup(String keySelector(T))
Creates dictionary whose elements are array containing the elements of the source.
keySelector is called with each element and returned the corresponding key.Enumerable.from([1,2,3,4,5]).toLookup("_%3"); // => %[0:[3], 1:[1,4], 2:[2,5]]
-
toDictionary(String keySelector(T), TElement elementSelector(T))
elementSelector is called with each element and returns the corresponding array element.Enumerable.from(["a","bc","de"]).toLookup("_.length", "_.toUpperCase()"); // => %[1:["A"], 2:["BC", "DE"]]
-
toDictionary(String keySelector(T, args*), TElement elementSelector(T, args*), args*)
All arguments are passed to keySelector and elementSelector.
Same as ForEach in Interactive Extensions.
-
forEach(bool callback(T))
Enumerates all the elements and invokes the callback for each element.
If the callback returns false, all the subsequent elements are ignored.
the corresponding array element.Enumerable.from([1,2,3]).forEach(function(x) { System.inform(x); // <= 1, 2, 3 });
-
forEach(bool callback(T, int))
callback can take an index as 2nd argument. -
forEach(bool callback(T, int, args*), args*)
All arguments are passed to callback.
Same as Do in Interactive Extensions.
-
do(void callback(T))
Invokes the callback for each elements.Enumerable.from([1,2,3]).do("Debug.message(_)"); // => 1,2,3
-
do(void callback(T, int))
callback can take an index as 2nd argument. -
do(void callback(T, int, args*), args*)
All arguments are passed to callback.
Same as Trace in linq.js.
-
trace()
Outputs all the elements by Debug.message.Enumerable.from([1,2,3]).trace(); // => 1,2,3
-
trace(void logger(T))
logger is called with each element. -
trace(void logger(T, int))
logger can take an index as 2nd argument. -
trace(void, logger(T, int, args*), args*)
All arguments are passed to logger.
Same as Force in linq.js.
-
force()
Enumerates all the elements and ignores all exceptions.Enumerable.from([1,2,3]).trace().force(); // 1,2,3 is outputted