fsprojects/FSharpx.Collections


LazyList<'T>

Namespace: FSharpx.Collections

LazyLists are possibly-infinite, cached sequences. See also IEnumerable/Seq for uncached sequences. LazyLists normally involve delayed computations without side-effects. The results of these computations are cached and evaluations will be performed only once for each element of the lazy list. In contrast, for sequences (IEnumerable) recomputation happens each time an enumerator is created and the sequence traversed.

LazyLists can represent cached, potentially-infinite computations. Because they are cached they may cause memory leaks if some active code or data structure maintains a live reference to the head of an infinite or very large lazy list while iterating it, or if a reference is maintained after the list is no longer required.

Lazy lists may be matched using the LazyList.Cons and LazyList.Nil active patterns. These may force the computation of elements of the list.

Instance members

Instance memberDescription
Head
Signature: 'T

O(1). Return the first element of the list. Forces the evaluation of the first cell of the list if it is not already evaluated.

CompiledName: get_Head

IsEmpty
Signature: bool

O(1). Test if a list is empty. Forces the evaluation of the first element of the stream if it is not already evaluated.

CompiledName: get_IsEmpty

Length()
Signature: unit -> int

O(n). Return the length of the list

Tail
Signature: LazyList<'T>

O(1). Return the list corresponding to the remaining items in the sequence.
Forces the evaluation of the first cell of the list if it is not already evaluated.

CompiledName: get_Tail

TryHead
Signature: 'T option

O(1). Return option the first element of the list. Forces the evaluation of the first cell of the list if it is not already evaluated.

CompiledName: get_TryHead

TryTail
Signature: LazyList<'T> option

O(1). Return option the list corresponding to the remaining items in the sequence.
Forces the evaluation of the first cell of the list if it is not already evaluated.

CompiledName: get_TryTail

TryUncons
Signature: ('T * LazyList<'T>) option

O(1). Returns option tuple of head element and tail of the list.

CompiledName: get_TryUncons

Uncons
Signature: 'T * LazyList<'T>

O(1). Returns tuple of head element and tail of the list.

CompiledName: get_Uncons

Fork me on GitHub