Ckini.Stream (Ckini v0.1.0) View Source
This module represents a stream data type.
It's usually used to store a stream of substitutions but can also be mapped to other types.
Link to this section Summary
Functions
Concat a stream of stream.
Like concat/1, but interleave a stream of stream instead.
This mplus function is the same implementation used in condi in other miniKanren implementations. It's generally more effective in searching the state tree comparing to those that uses interleave/concat. However, as you can see in the example below, the search order is difficult keep track of.
Link to this section Types
Link to this section Functions
Specs
Specs
Specs
Concat a stream of stream.
iex> [ ...> [0, 1, 2, 3], ...> [4, 5, 6], ...> [7], ...> [8] ...> ] ...> |> Enum.map(&from_list/1) ...> |> from_list() ...> |> concat() ...> |> to_list() [0, 1, 2, 3, 4, 5, 6, 7, 8]
Specs
Specs
Specs
empty() :: t()
Specs
Specs
Specs
Like concat/1, but interleave a stream of stream instead.
iex> [ ...> [0, 4, 6, 8], ...> [1, 5, 7], ...> [2], ...> [3] ...> ] ...> |> Enum.map(&from_list/1) ...> |> from_list() ...> |> interleave() ...> |> to_list() [0, 1, 2, 3, 4, 5, 6, 7, 8]
Specs
Specs
Specs
This mplus function is the same implementation used in condi in other miniKanren implementations. It's generally more effective in searching the state tree comparing to those that uses interleave/concat. However, as you can see in the example below, the search order is difficult keep track of.
You can use condem function to use this implementation.
iex> [ ...> [0, 1, 3, 4], ...> [2, 5, 7], ...> [6, 8], ...> [9] ...> ] ...> |> Enum.map(&from_list/1) ...> |> from_list() ...> |> mplus_many() ...> |> to_list() [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Specs
Specs
Specs
singleton(a()) :: t(a())
Specs
Specs
Specs
take(t(a()), non_neg_integer()) :: t(a())