Yaaf.FSharp.Helper


LazyList<'T>

Defined in Yaaf.FSharp.Helper.dll.

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.

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.

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.

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.

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.

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

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

Uncons
Signature: 'T * LazyList<'T>

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

Fork me on GitHub