Novah Documentation

novah.stream

Functions to work with Java streams.

Types

Declarations


empty

visibility: public
type: Unit -> Stream a

Creates a new empty stream.


from

visibility: public
type: a -> Stream a

Creates a stream with a single element.


forEach

visibility: public
type: Stream a -> (a -> b) -> Unit

Runs function f for every element of this Stream, ignoring the result. Runtime: O(n)


toArray

visibility: public
type: Stream a -> Array Object

Collects this Stream into an Array.


size

visibility: public
type: Stream a -> Int64

Returns the size of this stream.


filter

visibility: public
type: (a -> Boolean) -> Stream a -> Stream a

Returns a stream of the elements that match the given predicate.


map

visibility: public
type: (a -> b) -> Stream a -> Stream b

Maps function f over all elements of this Stream returning a Stream. Runtime: O(n)


flatMap

visibility: public
type: (a -> Stream b) -> Stream a -> Stream b

Like map but it will flatten the resulting stream.


limit

visibility: public
type: Int64 -> Stream a -> Stream a

Returns a new stream with a limited number of elements.


skip

visibility: public
type: Int64 -> Stream a -> Stream a

Returns a stream with the first n elements skipped.


takeWhile

visibility: public
type: (a -> Boolean) -> Stream a -> Stream a

Takes elements from this stream while the predicates holds.


dropWhile

visibility: public
type: (a -> Boolean) -> Stream a -> Stream a

Drops elements from this stream while the predicates holds.


reduce

visibility: public
type: (a -> a -> a) -> Stream a -> Option a

Reduces this stream to a single value according to the reducing function.


reduceInit

visibility: public
type: (a -> a -> a) -> a -> Stream a -> a

Reduces this stream to a single value according to the reducing function.