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

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 filter<T> (it:Iterable<T>, predicate:T ‑> Bool):Array<T>

Refer to Array.filter.

staticinline find<T, TFind> (it:Iterable<T>, predicate:T ‑> Bool):Null<T>

Refer to thx.Arrays.find.

staticinline findOption<T, TFind> (it:Iterable<T>, predicate:T ‑> Bool):Option<T>

staticinline first<T, TFind> (it:Iterable<T>):Null<T>

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 get<T> (it:Iterable<T>, index:Int):Null<T>

Get the element at the index position.

staticinline getOption<T> (it:Iterable<T>, index:Int):Option<T>

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.

staticinline isEmpty<T> (it:Iterable<T>):Bool

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 last<T, TFind> (it:Iterable<T>):Null<T>

Refer to thx.Arrays.last.

staticinline map<T, S> (it:Iterable<T>, f:T ‑> S):Array<S>

Refer to Array.map.

staticinline mapi<T, S> (it:Iterable<T>, f:T ‑> Int ‑> S):Array<S>

Refer to thx.Arrays.mapi.

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 order<T> (it:Iterable<T>, sort:T ‑> T ‑> Int):Array<T>

staticinline reduce<TElement, TAcc> (it:Iterable<TElement>, callback:TAcc ‑> TElement ‑> TAcc, initial:TAcc):TAcc

staticinline reducei<TElement, TAcc> (it:Iterable<TElement>, callback:TAcc ‑> TElement ‑> Int ‑> TAcc, initial:TAcc):TAcc

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 to a Tuple2, Array>.

staticunzip3<T1, T2, T3> (it:Iterable<Tuple3<T1, T2, T3>>):Tuple3<Array<T1>, Array<T2>, Array<T3>>

Unzip an iterable of Tuple3 to a Tuple3, Array, Array>.

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 to a Tuple4, Array, Array, Array>.

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 to a Tuple5, Array, Array, Array, Array>.

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.

staticzip4<T1, T2, T3, T4> (it1:Iterable<T1>, it2:Iterable<T2>, it3:Iterable<T3>, it4:Iterable<T4>):Array<Tuple4<T1, T2, T3, T4>>

Pairs the elements of four iterables in an array of Tuple4.

staticzip5<T1, T2, T3, T4, T5> (it1:Iterable<T1>, it2:Iterable<T2>, it3:Iterable<T3>, it4:Iterable<T4>, it5:Iterable<T5>):Array<Tuple5<T1, T2, T3, T4, T5>>

Pairs the elements of five iterables in an array of Tuple5.