|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectutil.fn.FnIterable<T>
T
- type of elements of the sequencepublic class FnIterable<T>
Functional programming like sequences. This class provides map-like functionality.
Method Summary | ||
---|---|---|
static
|
from(Iterable<T> it)
Creates a new functional sequence from an Iterable object |
|
Iterator<T> |
iterator()
|
|
|
map(Lambda<T,U> fn)
Maps function to sequence |
|
|
reduce(Lambda2<U,T,U> fn,
U initial)
Reduces this sequence to a value. |
|
List<T> |
toList()
|
|
|
zip(FnIterable<U> o)
Produces a sequence of pairs from two sequences. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <T> FnIterable<T> from(Iterable<T> it)
Iterable
object
T
- type of elements of the sequenceit
- the iterable object
public final <U> FnIterable<Pair<T,U>> zip(FnIterable<U> o)
{a1, a2, a3, ...}.zip({b1, b2, b3, ...}) ==> {(a1, b1), (a2, b2), (a3, b3), ...}
U
- type of elements of the argument sequenceo
- argument sequence to zip with
public final <U> FnIterable<U> map(Lambda<T,U> fn)
{a1, a2, a3, ...}.map(fn) ==> {fn(a1), fn(a2), fn(a3), ...}
U
- type of elements in result sequencefn
- function from elements in this sequence to elements of result sequence
public final <U> U reduce(Lambda2<U,T,U> fn, U initial)
{}.reduce(fn, initial) ==> initial {a1, a2, a3, ...}.reduce(fn, initial) ==> fn(... fn(fn(fn(initial, a1), a2), a3) ...)
U
- type of the resulting valuefn
- function to reduce sequenceinitial
- initial value to pass reducing function
public final List<T> toList()
public Iterator<T> iterator()
iterator
in interface Iterable<T>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |