LanguageExt.Core

LanguageExt.Core Immutable Collections IterableNE

Contents

Sub modules

Extensions
Operators
Trait

record IterableNE <A> (A Head, Iterable<A> Tail) Source #

Non-empty lazy-sequence

This always has a Head value and a Tail of length 0 to n.

Parameters

type A

Type of the values in the sequence

Methods

method IterableNE<A> FromSpan (ReadOnlySpan<A> ma) Source #

method int Count () Source #

Number of items in the sequence.

NOTE: This will force evaluation of the sequence

method IO<int> CountIO () Source #

Number of items in the sequence.

NOTE: This will force evaluation of the sequence

method IO<IEnumerable<A>> AsEnumerableIO () Source #

Stream as an enumerable

method IEnumerable<A> AsEnumerable (CancellationToken token = default) Source #

Stream as an enumerable

method IO<IAsyncEnumerable<A>> AsAsyncEnumerableIO () Source #

Stream as an enumerable

method IAsyncEnumerable<A> AsAsyncEnumerable (CancellationToken token = default) Source #

Stream as an enumerable

method Iterable<A> AsIterable () Source #

Stream as an enumerable

method IterableNE<A> Add (A item) Source #

Add an item to the end of the sequence

This does not force evaluation of the whole lazy sequence, nor does it cause exponential iteration issues when repeated adds occur.

method IterableNE<A> Cons (A item) Source #

Add an item to the beginning of the sequence

This does not force evaluation of the whole lazy sequence, nor does it cause exponential iteration issues when repeated cons occur.

method IO<Unit> IterIO (Action<A> f) Source #

Impure iteration of the bound values in the structure

Parameters

returns

Returns the original unmodified structure

method Unit Iter (Action<A> f) Source #

Impure iteration of the bound values in the structure

Parameters

returns

Returns the original unmodified structure

method IO<Unit> IterIO (Action<A, int> f) Source #

Impure iteration of the bound values in the structure

Parameters

returns

Returns the original unmodified structure

method Unit Iter (Action<A, int> f) Source #

Impure iteration of the bound values in the structure

Parameters

returns

Returns the original unmodified structure

method IterableNE<B> Map <B> (Func<A, B> f) Source #

Map the sequence using the function provided

Parameters

type B
param f

Mapping function

returns

Mapped sequence

method IterableNE<B> Map <B> (Func<A, int, B> f) Source #

Map the sequence using the function provided

Parameters

type B
param f

Mapping function

returns

Mapped sequence

method IterableNE<B> Bind <B> (Func<A, IterableNE<B>> f) Source #

Monadic bind (flatmap) of the sequence

Parameters

type B

Bound return value type

param f

Bind function

returns

Flat-mapped sequence

method Iterable<A> Filter (Func<A, bool> f) Source #

Filter the items in the sequence

Parameters

param f

Predicate to apply to the items

returns

Filtered sequence

method S FoldWhile <S> ( Func<A, Func<S, S>> f, Func<(S State, A Value), bool> predicate, S initialState) Source #

Fold over the sequence from the left, accumulating state in f

Parameters

type S

State value type

param f

Fold function to apply to each item in the sequence

param predicate

Continue while the predicate returns true for any pair of value and state. This is tested before the value is processed and the state is updated. So, use FoldWhile* for pre-assertions.

param initialState

Initial state value

returns

Resulting state

method S FoldWhile <S> ( Func<S, A, S> f, Func<(S State, A Value), bool> predicate, S initialState) Source #

Fold over the sequence from the left, accumulating state in f

Parameters

type S

State value type

param f

Fold function to apply to each item in the sequence

param predicate

Continue while the predicate returns true for any pair of value and state. This is tested before the value is processed and the state is updated. So, use FoldWhile* for pre-assertions.

param initialState

Initial state value

returns

Resulting state

method IO<S> FoldWhileIO <S> ( Func<A, Func<S, S>> f, Func<(S State, A Value), bool> predicate, S initialState) Source #

Fold over the sequence from the left, accumulating state in f

Parameters

type S

State value type

param f

Fold function to apply to each item in the sequence

param predicate

Continue while the predicate returns true for any pair of value and state. This is tested before the value is processed and the state is updated. So, use FoldWhile* for pre-assertions.

param initialState

Initial state value

returns

Resulting state

method IO<S> FoldWhileIO <S> ( Func<S, A, S> f, Func<(S State, A Value), bool> predicate, S initialState) Source #

Fold over the sequence from the left, accumulating state in f

Parameters

type S

State value type

param f

Fold function to apply to each item in the sequence

param predicate

Continue while the predicate returns true for any pair of value and state. This is tested before the value is processed and the state is updated. So, use FoldWhile* for pre-assertions.

param initialState

Initial state value

returns

Resulting state

method S FoldUntil <S> ( Func<A, Func<S, S>> f, Func<(S State, A Value), bool> predicate, S initialState) Source #

Fold over the sequence from the left, accumulating state in f

Parameters

type S

State value type

param f

Fold function to apply to each item in the sequence

param predicate

Continue while the predicate returns true for any pair of value and state. This is tested before the value is processed and the state is updated. So, use FoldWhile* for pre-assertions.

param initialState

Initial state value

returns

Resulting state

method S FoldUntil <S> ( Func<S, A, S> f, Func<(S State, A Value), bool> predicate, S initialState) Source #

Fold over the sequence from the left, accumulating state in f

Parameters

type S

State value type

param f

Fold function to apply to each item in the sequence

param predicate

Continue while the predicate returns true for any pair of value and state. This is tested before the value is processed and the state is updated. So, use FoldWhile* for pre-assertions.

param initialState

Initial state value

returns

Resulting state

method IO<S> FoldUntilIO <S> ( Func<A, Func<S, S>> f, Func<(S State, A Value), bool> predicate, S initialState) Source #

Fold over the sequence from the left, accumulating state in f

Parameters

type S

State value type

param f

Fold function to apply to each item in the sequence

param predicate

Continue while the predicate returns true for any pair of value and state. This is tested before the value is processed and the state is updated. So, use FoldWhile* for pre-assertions.

param initialState

Initial state value

returns

Resulting state

method IO<S> FoldUntilIO <S> ( Func<S, A, S> f, Func<(S State, A Value), bool> predicate, S initialState) Source #

Fold over the sequence from the left, accumulating state in f

Parameters

type S

State value type

param f

Fold function to apply to each item in the sequence

param predicate

Continue while the predicate returns true for any pair of value and state. This is tested before the value is processed and the state is updated. So, use FoldWhile* for pre-assertions.

param initialState

Initial state value

returns

Resulting state

method S FoldMaybe <S> ( Func<S, Func<A, Option<S>>> f, S initialState) Source #

Fold until the Option returns None

Parameters

type S

State type

param f

Fold function

param initialState

Initial state for the fold

param ta

Foldable structure

returns

Aggregated value

method S FoldMaybe <S> ( Func<S, A, Option<S>> f, S initialState) Source #

Fold until the Option returns None

Parameters

type S

State type

param f

Fold function

param initialState

Initial state for the fold

param ta

Foldable structure

returns

Aggregated value

method IO<S> FoldMaybeIO <S> ( Func<S, Func<A, Option<S>>> f, S initialState) Source #

Fold until the Option returns None

Parameters

type S

State type

param f

Fold function

param initialState

Initial state for the fold

param ta

Foldable structure

returns

Aggregated value

method IO<S> FoldMaybeIO <S> ( Func<S, A, Option<S>> f, S initialState) Source #

Fold until the Option returns None

Parameters

type S

State type

param f

Fold function

param initialState

Initial state for the fold

param ta

Foldable structure

returns

Aggregated value

method K<M, S> FoldWhileM <M, S> ( Func<A, Func<S, K<M, S>>> f, Func<A, bool> predicate, S initialState) Source #

where M : MonadIO<M>

Same behaviour as Fold but the fold operation returns a monadic type and allows early exit of the operation once the predicate function becomes false for the state/value pair

method K<M, S> FoldWhileM <M, S> ( Func<S, A, K<M, S>> f, Func<A, bool> predicate, S initialState) Source #

where M : MonadIO<M>

Same behaviour as Fold but the fold operation returns a monadic type and allows early exit of the operation once the predicate function becomes false for the state/value pair

method K<M, S> FoldUntilM <M, S> ( Func<A, Func<S, K<M, S>>> f, Func<A, bool> predicate, S initialState) Source #

where M : MonadIO<M>

Same behaviour as Fold but the fold operation returns a monadic type and allows early exit of the operation once the predicate function becomes false for the state/value pair

method K<M, S> FoldUntilM <M, S> ( Func<S, A, K<M, S>> f, Func<A, bool> predicate, S initialState) Source #

where M : MonadIO<M>

Same behaviour as Fold but the fold operation returns a monadic type and allows early exit of the operation once the predicate function becomes false for the state/value pair

method S Fold <S> (Func<A, Func<S, S>> f, S initialState) Source #

Right-associative fold of a structure, lazy in the accumulator.

In the case of lists, 'Fold', when applied to a binary operator, a starting value (typically the right-identity of the operator), and a list, reduces the list using the binary operator, from right to left.

method S Fold <S> (Func<S, A, S> f, S initialState) Source #

Right-associative fold of a structure, lazy in the accumulator.

In the case of lists, 'Fold', when applied to a binary operator, a starting value (typically the right-identity of the operator), and a list, reduces the list using the binary operator, from right to left.

method IO<S> FoldIO <S> (Func<A, Func<S, S>> f, S initialState) Source #

Right-associative fold of a structure, lazy in the accumulator.

In the case of lists, 'Fold', when applied to a binary operator, a starting value (typically the right-identity of the operator), and a list, reduces the list using the binary operator, from right to left.

method IO<S> FoldIO <S> (Func<S, A, S> f, S initialState) Source #

Right-associative fold of a structure, lazy in the accumulator.

In the case of lists, 'Fold', when applied to a binary operator, a starting value (typically the right-identity of the operator), and a list, reduces the list using the binary operator, from right to left.

method K<M, S> FoldM <M, S> ( Func<A, Func<S, K<M, S>>> f, S initialState) Source #

where M : MonadIO<M>

Right-associative fold of a structure, lazy in the accumulator.

In the case of lists, 'Fold', when applied to a binary operator, a starting value (typically the right-identity of the operator), and a list, reduces the list using the binary operator, from right to left.

method K<M, S> FoldM <M, S> ( Func<S, A, K<M, S>> f, S initialState) Source #

where M : MonadIO<M>

Right-associative fold of a structure, lazy in the accumulator.

In the case of lists, 'Fold', when applied to a binary operator, a starting value (typically the right-identity of the operator), and a list, reduces the list using the binary operator, from right to left.

method B FoldMap <B> (Func<A, B> f) Source #

where B : Monoid<B>

Map each element of the structure into a monoid, and combine the results with Append. This fold is right-associative and lazy in the accumulator. For strict left-associative folds consider FoldMapBack instead.

method IO<B> FoldMapIO <B> (Func<A, B> f) Source #

where B : Monoid<B>

Map each element of the structure into a monoid, and combine the results with Append. This fold is right-associative and lazy in the accumulator. For strict left-associative folds consider FoldMapBack instead.

method B FoldMapWhile <B> (Func<A, B> f, Func<(B State, A Value), bool> predicate) Source #

where B : Monoid<B>

Map each element of the structure into a monoid, and combine the results with Append. This fold is right-associative and lazy in the accumulator. For strict left-associative folds consider FoldMapBack instead.

method IO<B> FoldMapWhileIO <B> (Func<A, B> f, Func<(B State, A Value), bool> predicate) Source #

where B : Monoid<B>

Map each element of the structure into a monoid, and combine the results with Append. This fold is right-associative and lazy in the accumulator. For strict left-associative folds consider FoldMapBack instead.

method B FoldMapUntil <B> (Func<A, B> f, Func<(B State, A Value), bool> predicate) Source #

where B : Monoid<B>

Map each element of the structure into a monoid, and combine the results with Append. This fold is right-associative and lazy in the accumulator. For strict left-associative folds consider FoldMapBack instead.

method IO<B> FoldMapUntilIO <B> (Func<A, B> f, Func<(B State, A Value), bool> predicate) Source #

where B : Monoid<B>

Map each element of the structure into a monoid, and combine the results with Append. This fold is right-associative and lazy in the accumulator. For strict left-associative folds consider FoldMapBack instead.

method IterableNE<A> Combine (IterableNE<A> y) Source #

Semigroup combine two iterables (concatenate)

method IterableNE<A> Concat (IEnumerable<A> items) Source #

Add a range of items to the end of the sequence

method IterableNE<A> Concat (Iterable<A> items) Source #

Add a range of items to the end of the sequence

method IterableNE<A> Concat (IterableNE<A> items) Source #

Add a range of items to the end of the sequence

method IterableNE<B> Bind <B> (Func<A, K<IterableNE, B>> f) Source #

Monadic bind (flatmap) of the sequence

Parameters

type B

Bound return value type

param f

Bind function

returns

Flat-mapped sequence

method bool Any () Source #

Returns true if the sequence has items in it

Parameters

returns

True if the sequence has items in it

method int CompareTo (object? obj) Source #

method int CompareTo (IterableNE<A>? other) Source #

method IO<int> CompareToIO (IterableNE<A>? other) Source #

method int CompareTo <OrdA> (IterableNE<A>? rhs) Source #

where OrdA : Ord<A>

Compare to another sequence

method IO<int> CompareToIO <OrdA> (IterableNE<A>? rhs) Source #

where OrdA : Ord<A>

Compare to another sequence

method string ToString () Source #

Format the collection as [a, b, c, ...] The ellipsis is used for collections over 50 items To get a formatted string with all the items, use ToFullString or ToFullArrayString.

method IO<string> ToStringIO () Source #

Format the collection as [a, b, c, ...] The ellipsis is used for collections over 50 items To get a formatted string with all the items, use ToFullString or ToFullArrayString.

method string ToFullString (string separator = ", ") Source #

Format the collection as a, b, c, ...

method IO<string> ToFullStringIO (string separator = ", ") Source #

Format the collection as a, b, c, ...

method string ToFullArrayString (string separator = ", ") Source #

Format the collection as [a, b, c, ...]

method IO<string> ToFullArrayStringIO (string separator = ", ") Source #

Format the collection as [a, b, c, ...]

method Iterable<A> Skip (int amount) Source #

Skip count items

method Iterable<A> Take (int amount) Source #

Take count items

method Iterable<A> TakeWhile (Func<A, bool> pred) Source #

Iterate the sequence, yielding items if they match the predicate provided, and stopping as soon as one doesn't

Parameters

returns

A new sequence with the first items that match the predicate

method Iterable<A> TakeWhile (Func<A, int, bool> pred) Source #

Iterate the sequence, yielding items if they match the predicate provided, and stopping as soon as one doesn't. An index value is also provided to the predicate function.

Parameters

returns

A new sequence with the first items that match the predicate

method (Iterable<A> First, Iterable<A> Second) Partition (Func<A, bool> predicate) Source #

method IterableNE<(A First, B Second)> Zip <B> (IterableNE<B> rhs) Source #

Zip two iterables into pairs

method IterableNE<C> Zip <B, C> (IterableNE<B> rhs, Func<A, B, C> zipper) Source #

Zip two iterables into pairs

method IterableNE<B> Select <B> (Func<A, B> f) Source #

Map the sequence using the function provided

Parameters

type B
param f

Mapping function

returns

Mapped sequence

method IterableNE<B> Select <B> (Func<A, int, B> f) Source #

Map the sequence using the function provided

Parameters

type B
param f

Mapping function

returns

Mapped sequence

method IterableNE<B> SelectMany <B> (Func<A, IterableNE<B>> bind) Source #

Monadic bind (flatmap) of the sequence

Parameters

type B

Bound return value type

param bind

Bind function

returns

Flat-mapped sequence

method IterableNE<C> SelectMany <B, C> (Func<A, IterableNE<B>> bind, Func<A, B, C> project) Source #

Monadic bind (flatmap) of the sequence

Parameters

type B

Bound return value type

param bind

Bind function

returns

Flat-mapped sequence

method IEnumerator<A> GetEnumerator () Source #

method int GetHashCode () Source #

Get the hash code for all the items in the sequence, or 0 if empty

Parameters

returns

Operators

operator + (IterableNE<A> x, IterableNE<A> y) Source #

Append operator

operator + (IterableNE<A> x, Iterable<A> y) Source #

Append operator

operator > (IterableNE<A> x, IterableNE<A> y) Source #

Ordering operator

operator >= (IterableNE<A> x, IterableNE<A> y) Source #

Ordering operator

operator < (IterableNE<A> x, IterableNE<A> y) Source #

Ordering operator

operator <= (IterableNE<A> x, IterableNE<A> y) Source #

Ordering operator

class IterableNE Source #

Cons sequence module Represents a sequence of values in a similar way to IEnumerable, but without the issues of multiple evaluation for key LINQ operators like Skip, Count, etc.

Parameters

type A

Type of the values in the sequence

Methods

method Option<IterableNE<A>> flatten <A> (IterableNE<IterableNE<A>> ma) Source #

Monadic join

method IterableNE<A> singleton <A> (A value) Source #

Create an empty sequence

method IterableNE<A> create <A> (A head, params ReadOnlySpan<A> tail) Source #

Create a sequence from an initial set of items

Parameters

param items

Items

returns

sequence

method IterableNE<A> create <A> (A head, IEnumerable<A> tail) Source #

Create a sequence from an initial set of items

Parameters

param items

Items

returns

sequence

method IterableNE<A> create <A> (A head, IAsyncEnumerable<A> tail) Source #

Create a sequence from an initial set of items

Parameters

param items

Items

returns

sequence

method IterableNE<A> create <A> (A head, Iterable<A> tail) Source #

Create a sequence from an initial set of items

Parameters

param items

Items

returns

sequence

method IterableNE<A> create <A> (A head, IterableNE<A> tail) Source #

Create a sequence from an initial set of items

Parameters

param items

Items

returns

sequence

method Option<IterableNE<A>> createRange <A> (ReadOnlySpan<A> items) Source #

Create a sequence from an initial set of items

Parameters

param items

Items

returns

sequence

method Option<IterableNE<A>> createRange <A> (IEnumerable<A> items) Source #

Create a sequence from an initial set of items

Parameters

param items

Items

returns

sequence

method IO<IterableNE<A>> createRange <A> (IAsyncEnumerable<A> items) Source #

Create a sequence from an initial set of items

Parameters

param items

Items

returns

sequence

method IO<IterableNE<A>> createRange <A> (Iterable<A> items) Source #

Create a sequence from an initial set of items

Parameters

param items

Items

returns

sequence

method Option<IterableNE<A>> generate <A> (int count, Func<int, A> generator) Source #

Generates a sequence of A using the provided delegate to initialise each item.

method Option<IterableNE<A>> repeat <A> (A item, int count) Source #

Generates a sequence that contains one repeated value.

method A head <A> (IterableNE<A> list) Source #

Get the item at the head (first) of the sequence

Parameters

param list

sequence

returns

Head item

method Iterable<B> choose <A, B> (IterableNE<A> list, Func<A, Option<B>> selector) Source #

Applies the given function 'selector' to each element of the sequence. Returns the sequence of results for each element where the function returns Some(f(x)).

Parameters

type A

sequence item type

param list

sequence

param selector

Selector function

returns

Mapped and filtered sequence

method IterableNE<C> zip <A, B, C> (IterableNE<A> list, IterableNE<B> other, Func<A, B, C> zipper) Source #

Joins two sequences together either into a single sequence using the join function provided

Parameters

param list

First sequence to join

param other

Second sequence to join

param zipper

Join function

returns

Joined sequence

method IterableNE<(A First, B Second)> zip <A, B> (IterableNE<A> list, IterableNE<B> other) Source #

Joins two sequences together either into an sequence of tuples

Parameters

param list

First sequence to join

param other

Second sequence to join

param zipper

Join function

returns

Joined sequence of tuples

method Iterable<A> take <A> (IterableNE<A> list, int count) Source #

Returns a new sequence with the first 'count' items from the sequence provided

Parameters

type A

sequence item type

param list

sequence

param count

Number of items to take

returns

A new sequence with the first 'count' items from the sequence provided

method Iterable<A> takeWhile <A> (IterableNE<A> list, Func<A, bool> pred) Source #

Iterate the sequence, yielding items if they match the predicate provided, and stopping as soon as one doesn't

Parameters

type A

sequence item type

param list

sequence

param count

Number of items to take

returns

A new sequence with the first items that match the predicate

method Iterable<A> takeWhile <A> (IterableNE<A> list, Func<A, int, bool> pred) Source #

Iterate the sequence, yielding items if they match the predicate provided, and stopping as soon as one doesn't. An index value is also provided to the predicate function.

Parameters

type A

sequence item type

param list

sequence

param count

Number of items to take

returns

A new sequence with the first items that match the predicate