Markov.ListUtil (markov v4.1.3)

Link to this section Summary

Functions

Splits the list into size-sized lists of consecutive elements

Link to this section Functions

Link to this function

overlapping_stride(list, size)

@spec overlapping_stride(list(), non_neg_integer()) :: list()

Splits the list into size-sized lists of consecutive elements

example

Example

iex> Markov.ListUtil.overlapping_stride([:a, :b, :c, :d, :e, :f, :g], 3)
[[:a, :b, :c], [:b, :c, :d], [:c, :d, :e], [:d, :e, :f], [:e, :f, :g]]

iex> Markov.ListUtil.overlapping_stride([:a, :b, :c, :d, :e, :f, :g], 2)
[[:a, :b], [:b, :c], [:c, :d], [:d, :e], [:e, :f], [:f, :g]]