class Iterables
package thx
Helper class for Iterable
. Implementations usually fallback on thx.Iterators
.
For documentation of specific methods refer to the equivalent methods in thx.Arrays
;
Static methods
staticall<T> (it:Iterable<T>, predicate:T ‑> Bool):Bool
Checks if predicate
returns true for all elements in the iterable.
staticany<T> (it:Iterable<T>, predicate:T ‑> Bool):Bool
Checks if predicate
returns true for at least one element in the iterable.
staticdifferenceBy<T> (a:Iterable<T>, b:Iterable<T>, eq:T ‑> T ‑> Bool):Array<T>
Returns an Array that contains all elements from a which are not elements of b. If a contains duplicates, the resulting Array contains duplicates.
staticdropLeft<A> (itr:Iterable<A>, n:Int):Iterable<A>
Produces an Array from a[n]
to the last element of a
.
staticdropUntil<A> (it:Iterable<A>, fn:A ‑> Bool):Array<A>
Drop values until the first time fn
produced false.
staticinline eachPair<TIn, TOut> (it:Iterable<TIn>, handler:TIn ‑> TIn ‑> Bool):Void
Refer to thx.Arrays.eachPair
.
staticinline equals<T> (a:Iterable<T>, b:Iterable<T>, ?equality:T ‑> T ‑> Bool):Bool
It compares the lengths and elements of two given iterables and returns true
if they match.
An optional equality function can be passed as the last argument. If not provided, strict equality is adopted.
staticinline extrema<A> (it:Iterable<A>, ord:Ord<A>):Option<Tuple<A, A>>
extrema
finds both the minimum and maximum value included in the iterable,
as compared by the specified ordering.
staticextremaBy<A, B> (it:Iterable<A>, f:A ‑> B, ord:Ord<B>):Option<Tuple<A, A>>
extremaBy
finds both the minimum and maximum value included in the iterable,
as compared by some function of the values contained within the iterable and
the specified ordering.
staticinline findOption<T, TFind> (it:Iterable<T>, predicate:T ‑> Bool):Option<T>
Refer to thx.Arrays.findOption
.
staticinline fmap<T, S> (it:Iterable<T>, f:T ‑> S):Iterable<S>
A proper Functor-like map function that preverses iterable structure.
staticinline fmapi<T, S> (it:Iterable<T>, f:T ‑> Int ‑> S):Iterable<S>
A proper Functor-like mapi function that preverses iterable structure, with index information.
staticinline hasElements<T> (it:Iterable<T>):Bool
Returns true
if the iterable contains at least one element.
staticinline indexOf<T> (it:Iterable<T>, element:T):Int
Returns the position of element in the iterable. It returns -1 if not found.
staticisIterable (v:Dynamic):Bool
isIterable
checks that the passed argument has all the requirements to be an Iterable
.
Note that no type checking is performed at runtime, only if a method iterator
exists regardless
of its signature.
staticinline max<A> (it:Iterable<A>, ord:Ord<A>):Option<A>
max
finds the maximum value included in the iterable, accorrding
to the specified ordering.
staticinline maxBy<A, B> (it:Iterable<A>, f:A ‑> B, ord:Ord<B>):Option<A>
maxBy
finds the maximum value included in the iterable, as compared by some
function of the values contained within the iterable.
staticinline min<A> (it:Iterable<A>, ord:Ord<A>):Option<A>
min
finds the minimum value included in the iterable, accorrding
to the specified ordering.
staticminBy<A, B> (it:Iterable<A>, f:A ‑> B, ord:Ord<B>):Option<A>
minBy
finds the minimum value included in the iterable, as compared by some
function of the values contained within the iterable.
staticinline reduce<TElement, TAcc> (it:Iterable<TElement>, callback:TAcc ‑> TElement ‑> TAcc, initial:TAcc):TAcc
Refer to thx.Arrays.reduce
.
staticinline reducei<TElement, TAcc> (it:Iterable<TElement>, callback:TAcc ‑> TElement ‑> Int ‑> TAcc, initial:TAcc):TAcc
Refer to thx.Arrays.reducei
.
statictakeUntil<A> (it:Iterable<A>, fn:A ‑> Bool):Array<A>
Take values until the first time fn
produced false.
staticinline toArray<T> (it:Iterable<T>):Array<T>
toArray
transforms an Iterable<T>
into an Array<T>
.
staticunionBy<T> (a:Iterable<T>, b:Iterable<T>, eq:T ‑> T ‑> Bool):Array<T>
Returns an Array that contains all elements from a which are also elements of b. If a contains duplicates, so will the result.
staticunzip<T1, T2> (it:Iterable<Tuple2<T1, T2>>):Tuple2<Array<T1>, Array<T2>>
Unzip an iterable of Tuple2
staticunzip3<T1, T2, T3> (it:Iterable<Tuple3<T1, T2, T3>>):Tuple3<Array<T1>, Array<T2>, Array<T3>>
Unzip an iterable of Tuple3
staticunzip4<T1, T2, T3, T4> (it:Iterable<Tuple4<T1, T2, T3, T4>>):Tuple4<Array<T1>, Array<T2>, Array<T3>, Array<T4>>
Unzip an iterable of Tuple4
staticunzip5<T1, T2, T3, T4, T5> (it:Iterable<Tuple5<T1, T2, T3, T4, T5>>):Tuple5<Array<T1>, Array<T2>, Array<T3>, Array<T4>, Array<T5>>
Unzip an iterable of Tuple5
staticzip<T1, T2> (it1:Iterable<T1>, it2:Iterable<T2>):Array<Tuple2<T1, T2>>
Pairs the elements of two iterables in an array of Tuple2
.
staticzip3<T1, T2, T3> (it1:Iterable<T1>, it2:Iterable<T2>, it3:Iterable<T3>):Array<Tuple3<T1, T2, T3>>
Pairs the elements of three iterables in an array of Tuple3
.