Functions - lang.stream

close

Closes a stream. This releases any system resources being used by the stream.

filter

Selects the members from a stream for which a function returns true.

forEach

Applies a function to each member of a stream. The Combining function is applied to each member of stream in order.

iterator

Returns an iterator over a stream.

map

Applies a function to each member of a stream and returns a stream of the results.

next

Returns the next element in the stream wrapped in a record or () if the stream ends.

reduce

Combines the members of a stream using a combining function. The combining function takes the combined value so far and a member of the stream, and returns a new combined value.

close

(stream stm)

returns ErrorType?

Closes a stream. This releases any system resources being used by the stream.

Parameters

  • stm stream
  • the stream to close

  • Return Type

    (ErrorType?)
  • () if the close completed successfully, otherwise an error

filter

(stream stm, function(Type) returns (boolean) func)

returns stream

Selects the members from a stream for which a function returns true.

Parameters

  • stm stream
  • the stream

  • func function(Type) returns (boolean)
  • a predicate to apply to each member to test whether it should be selected

  • Return Type

    (stream)
  • new stream only containing members of stm for which func evaluates to true

forEach

(stream stm, function(Type) returns (()) func)

returns ErrorType?

Applies a function to each member of a stream. The Combining function is applied to each member of stream in order.

Parameters

  • stm stream
  • the stream

  • func function(Type) returns (())
  • a function to apply to each member

  • Return Type

    (ErrorType?)
  • An error if iterating the stream encounters an error

iterator

(stream stm)

returns $anonType$6

Returns an iterator over a stream.

Parameters

  • stm stream
  • the stream

  • Return Type

    ($anonType$6)
  • a new iterator object that will iterate over the members of stm.

map

(stream stm, function(Type) returns (Type1) func)

returns stream

Applies a function to each member of a stream and returns a stream of the results.

Parameters

  • stm stream
  • the stream

  • func function(Type) returns (Type1)
  • a function to apply to each member

  • Return Type

    (stream)
  • new stream containing result of applying func to each member of stm in order

Returns the next element in the stream wrapped in a record or () if the stream ends.

Parameters

  • strm stream
  • The stream

  • Return Type

    ($anonType$1 | ErrorType | ())
  • If the stream has elements, return the element wrapped in a record with single field called value, otherwise returns ()

reduce

(stream stm, function(Type1, Type) returns (Type1) func, Type1 initial)

returns Type1 | ErrorType

Combines the members of a stream using a combining function. The combining function takes the combined value so far and a member of the stream, and returns a new combined value.

Parameters

  • stm stream
  • the stream

  • func function(Type1, Type) returns (Type1)
  • combining function

  • initial Type1
  • initial value for the first argument of combining function

  • Return Type

    (Type1 | ErrorType)
  • result of combining the members of stm using the combining function