induce

fun <Element> KoneSequence.Companion.induce(size: UInt, initialElement: Element, inducer: (index: UInt, previous: Element) -> Element): KoneSequence<Element>(source)

Creates a finite KoneSequence by induction: starting from initialElement, each subsequent element is produced by applying inducer to the previous element.

I.e. it's a (lazily evaluated) sequence of elements (e0, e1, e2, ...) where e0 = initialElement, e1 = inducer(1u, e0), e2 = inducer(2u, e1), and so on.

Return

A new KoneSequence instance.

Parameters

size

The number of elements in the sequence.

initialElement

The first element of the sequence.

inducer

The function that produces the next element given the next index and previous element.

Type Parameters

Element

The type of elements.


fun <Element> KoneSequence.Companion.induce(indices: UIntRange, initialElement: Element, inducer: (index: UInt, previous: Element) -> Element): KoneSequence<Element>(source)

Creates a KoneSequence by induction over the given indices range: starting from initialElement, each subsequent element is produced by applying inducer to the previous element.

I.e. it's a (lazily evaluated) sequence of elements (e0, e1, e2, ...) where e0 = initialElement, e1 = inducer(indices.start, e0), e2 = inducer(indices.start + 1u, e1), and so on.

Return

A new KoneSequence instance.

Parameters

indices

The range of indices to induce elements for.

initialElement

The first element of the sequence.

inducer

The function that produces the next element given the index and previous element.

Type Parameters

Element

The type of elements.


fun <Element> KoneSequence.Companion.induce(initialElement: Element, inducer: (index: UInt, previous: Element) -> Element): KoneSequence<Element>(source)

Creates an infinite KoneSequence by induction: starting from initialElement, each subsequent element is produced by applying inducer to the previous element.

I.e. it's a (lazily evaluated) sequence of elements (e0, e1, e2, ...) where e0 = initialElement, e1 = inducer(1u, e0), e2 = inducer(2u, e1), and so on.

Return

An infinite KoneSequence instance.

Parameters

initialElement

The first element of the sequence.

inducer

The function that produces the next element given the index and previous element.

Type Parameters

Element

The type of elements.