FSharpx.Collections


LazyList<'T> Type

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 member Description

this.Head

Full Usage: this.Head

Returns: '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.

Returns: 'T

this.IsEmpty

Full Usage: this.IsEmpty

Returns: 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.

Returns: bool

this.Length()

Full Usage: this.Length()

Returns: int

O(n). Return the length of the list

Returns: int

this.Tail

Full Usage: this.Tail

Returns: 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.

Returns: LazyList<'T>

this.TryHead

Full Usage: this.TryHead

Returns: '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.

Returns: 'T option

this.TryTail

Full Usage: this.TryTail

Returns: 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.

Returns: LazyList<'T> option

this.TryUncons

Full Usage: this.TryUncons

Returns: ('T * LazyList<'T>) option

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

Returns: ('T * LazyList<'T>) option

this.Uncons

Full Usage: this.Uncons

Returns: 'T * LazyList<'T>

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

Returns: 'T * LazyList<'T>