- Iterable <A>
- FromSpan (ReadOnlySpan<A> ma)
- Count ()
- AsEnumerable ()
- AsStream <M> ()
- Reverse ()
- Add (A item)
- Cons (A item)
- Iter (Action<A> f)
- Iter (Action<A, int> f)
- Map <B> (Func<A, B> f)
- Map <B> (Func<A, int, B> f)
- Bind <B> (Func<A, Iterable<B>> f)
- Filter (Func<A, bool> f)
- Equals (Iterable<A>? other)
- Equals (object? obj)
- == (Iterable<A>? lhs, Iterable<A>? rhs)
- != (Iterable<A>? lhs, Iterable<A>? rhs)
- FoldWhile <S> ( Func<A, Func<S, S>> f, Func<(S State, A Value), bool> predicate, S state)
- FoldWhile <S> ( Func<S, A, S> f, Func<(S State, A Value), bool> predicate, S state)
- FoldBackWhile <S> ( Func<S, Func<A, S>> f, Func<(S State, A Value), bool> predicate, S state)
- FoldBackWhile <S> ( Func<S, A, S> f, Func<(S State, A Value), bool> predicate, S state)
- Combine (Iterable<A> y)
- Concat (IEnumerable<A> items)
- Concat (Iterable<A> items)
- Scan <S> (S state, Func<S, A, S> folder)
- ScanBack <S> (S state, Func<S, A, S> folder)
- Distinct <EqA> ()
- Distinct ()
- Traverse <F, B> (Func<A, K<F, B>> f)
- TraverseM <M, B> (Func<A, K<M, B>> f)
- Bind <B> (Func<A, K<Iterable, B>> f)
- Bind <B> (Func<A, IEnumerable<B>> f)
- Any ()
- Intersperse (A value)
- CompareTo (object? obj)
- CompareTo (Iterable<A>? other)
- CompareTo <OrdA> (Iterable<A>? rhs)
- ToString ()
- ToFullString (string separator = ", ")
- ToFullArrayString (string separator = ", ")
- Equals <EqA> (Iterable<A> rhs)
- Skip (int amount)
- Take (int amount)
- TakeWhile (Func<A, bool> pred)
- TakeWhile (Func<A, int, bool> pred)
- Partition (Func<A, bool> predicate)
- Cast <B> ()
- Zip <B> (Iterable<B> rhs)
- Zip <B, C> (Iterable<B> rhs, Func<A, B, C> zipper)
- Empty
- + (Iterable<A> x, Iterable<A> y)
- | (Iterable<A> x, K<Iterable, A> y)
- | (K<Iterable, A> x, Iterable<A> y)
- > (Iterable<A> x, Iterable<A> y)
- >= (Iterable<A> x, Iterable<A> y)
- < (Iterable<A> x, Iterable<A> y)
- <= (Iterable<A> x, Iterable<A> y)
- Select <B> (Func<A, B> f)
- Select <B> (Func<A, int, B> f)
- Where (Func<A, bool> f)
- SelectMany <B> (Func<A, Iterable<B>> bind)
- SelectMany <B, C> (Func<A, Iterable<B>> bind, Func<A, B, C> project)
- SelectMany <B> (Func<A, IEnumerable<B>> bind)
- SelectMany <B, C> (Func<A, IEnumerable<B>> bind, Func<A, B, C> project)
- GetEnumerator ()
- GetHashCode ()
- AdditiveIdentity
- IterableExtensions
- As <A> (this K<Iterable, A> xs)
- AsIterable <A> (this IEnumerable<A> xs)
- Flatten <A> (this Iterable<Iterable<A>> ma)
- Choose <A, B> (this Iterable<A> list, Func<A, Option<B>> selector)
- Rev <T> (this Iterable<T> list)
- IterableExtensions
- Map <A, B> (this Func<A, B> f, K<Iterable, A> ma)
- Map <A, B> (this Func<A, B> f, Iterable<A> ma)
- Action <A, B> (this K<Iterable, A> ma, K<Iterable, B> mb)
- Action <A, B> (this Iterable<A> ma, K<Iterable, B> mb)
- Apply <A, B> (this Iterable<Func<A, B>> mf, K<Iterable, A> ma)
- Apply <A, B> (this K<Iterable, Func<A, B>> mf, K<Iterable, A> ma)
- Iterable
- flatten <A> (Iterable<Iterable<A>> ma)
- empty <A> ()
- singleton <A> (A value)
- create <A> ()
- create <A> (params A[] items)
- createRange <A> (ReadOnlySpan<A> items)
- createRange <A> (IEnumerable<A> items)
- generate <A> (int count, Func<int, A> generator)
- repeat <A> (A item, int count)
- head <A> (Iterable<A> list)
- choose <A, B> (Iterable<A> list, Func<A, Option<B>> selector)
- rev <A> (Iterable<A> list)
- scan <S, A> (Iterable<A> list, S state, Func<S, A, S> folder)
- scanBack <S, A> (Iterable<A> list, S state, Func<S, A, S> folder)
- zip <A, B, C> (Iterable<A> list, Iterable<B> other, Func<A, B, C> zipper)
- zip <A, B> (Iterable<A> list, Iterable<B> other)
- distinct <A> (Iterable<A> list)
- distinct <EqA, A> (Iterable<A> list)
- take <A> (Iterable<A> list, int count)
- takeWhile <A> (Iterable<A> list, Func<A, bool> pred)
- takeWhile <A> (Iterable<A> list, Func<A, int, bool> pred)
- Iterable
- Prelude
Lazy sequence
This is a lightweight wrapper around IEnumerable
that also implements traits
that make it play nice with other types in this library: Monad, Traversable, etc.
type | A | Type of the values in the sequence |
property Iterable<A> AdditiveIdentity Source #
Get the additive-identity, i.e. the monoid-zero. Which is the empty sequence/
Number of items in the sequence.
NOTE: This will force evaluation of the sequence
method IEnumerable<A> AsEnumerable () Source #
Stream as an enumerable
method Iterable<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 Iterable<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 Unit Iter (Action<A> f) Source #
Impure iteration of the bound values in the structure
returns | Returns the original unmodified structure |
method Unit Iter (Action<A, int> f) Source #
Impure iteration of the bound values in the structure
returns | Returns the original unmodified structure |
method Iterable<B> Map <B> (Func<A, B> f) Source #
Map the sequence using the function provided
type | B | |
param | f | Mapping function |
returns | Mapped sequence |
method Iterable<B> Map <B> (Func<A, int, B> f) Source #
Map the sequence using the function provided
type | B | |
param | f | Mapping function |
returns | Mapped sequence |
method Iterable<B> Bind <B> (Func<A, Iterable<B>> f) Source #
Monadic bind (flatmap) of the sequence
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
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 state) Source #
method S FoldWhile <S> ( Func<S, A, S> f, Func<(S State, A Value), bool> predicate, S state) Source #
method S FoldBackWhile <S> ( Func<S, Func<A, S>> f, Func<(S State, A Value), bool> predicate, S state) Source #
method S FoldBackWhile <S> ( Func<S, A, S> f, Func<(S State, A Value), bool> predicate, S state) Source #
method Iterable<A> Concat (IEnumerable<A> items) Source #
Add a range of items to the end of the sequence
method Iterable<A> Concat (Iterable<A> items) Source #
Add a range of items to the end of the sequence
method Iterable<S> Scan <S> (S state, Func<S, A, S> folder) Source #
Applies a function to each element of the sequence, threading an accumulator argument through the computation. This function takes the state argument, and applies the function to it and the first element of the sequence. Then, it passes this result into the function along with the second element, and so on. Finally, it returns the list of intermediate results and the final result.
type | S | State type |
type | T | sequence item type |
param | state | Initial state |
param | folder | Folding function |
returns | Aggregate state |
method Iterable<S> ScanBack <S> (S state, Func<S, A, S> folder) Source #
Applies a function to each element of the sequence (from last element to first), threading an accumulator argument through the computation. This function takes the state argument, and applies the function to it and the first element of the sequence. Then, it passes this result into the function along with the second element, and so on. Finally, it returns the list of intermediate results and the final result.
type | S | State type |
param | state | Initial state |
param | folder | Folding function |
returns | Aggregate state |
method Iterable<A> Distinct <EqA> () Source #
Return a new sequence with all duplicate values removed
type | T | sequence item type |
returns | A new sequence with all duplicate values removed |
method Iterable<A> Distinct () Source #
Return a new sequence with all duplicate values removed
type | T | sequence item type |
returns | A new sequence with all duplicate values removed |
method K<F, Iterable<B>> Traverse <F, B> (Func<A, K<F, B>> f) Source #
Map each element of a structure to an action, evaluate these actions from left to right, and collect the results.
type | F | Applicative functor trait |
type | B | Bound value (output) |
param | f | |
param | ta | Traversable structure |
method K<M, Iterable<B>> TraverseM <M, B> (Func<A, K<M, B>> f) Source #
Map each element of a structure to an action, evaluate these actions from left to right, and collect the results.
type | M | Monad trait |
type | B | Bound value (output) |
param | f | |
param | ta | Traversable structure |
method Iterable<B> Bind <B> (Func<A, K<Iterable, B>> f) Source #
Monadic bind (flatmap) of the sequence
type | B | Bound return value type |
param | f | Bind function |
returns | Flat-mapped sequence |
method Iterable<B> Bind <B> (Func<A, IEnumerable<B>> f) Source #
Monadic bind (flatmap) of the sequence
type | B | Bound return value type |
param | f | Bind function |
returns | Flat-mapped sequence |
Returns true if the sequence has items in it
returns | True if the sequence has items in it |
method Iterable<A> Intersperse (A value) Source #
Inject a value in between each item in the sequence
type | A | Bound type |
param | ma | Sequence to inject values into |
param | value | Item to inject |
returns | A sequence with the values injected |
method int CompareTo <OrdA> (Iterable<A>? rhs) Source #
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 string ToFullString (string separator = ", ") Source #
Format the collection as a, b, c, ...
method string ToFullArrayString (string separator = ", ") Source #
Format the collection as [a, b, c, ...]
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
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.
returns | A new sequence with the first items that match the predicate |
method Iterable<B> Cast <B> () Source #
Cast items to another type
Any item in the sequence that can't be cast to a B
will be dropped from the result
method Iterable<(A First, B Second)> Zip <B> (Iterable<B> rhs) Source #
Zip two iterables into pairs
method Iterable<C> Zip <B, C> (Iterable<B> rhs, Func<A, B, C> zipper) Source #
Zip two iterables into pairs
method Iterable<B> Select <B> (Func<A, B> f) Source #
Map the sequence using the function provided
type | B | |
param | f | Mapping function |
returns | Mapped sequence |
method Iterable<B> Select <B> (Func<A, int, B> f) Source #
Map the sequence using the function provided
type | B | |
param | f | Mapping function |
returns | Mapped sequence |
method Iterable<A> Where (Func<A, bool> f) Source #
Filter the items in the sequence
param | f | Predicate to apply to the items |
returns | Filtered sequence |
method Iterable<B> SelectMany <B> (Func<A, Iterable<B>> bind) Source #
Monadic bind (flatmap) of the sequence
type | B | Bound return value type |
param | bind | Bind function |
returns | Flat-mapped sequence |
method Iterable<C> SelectMany <B, C> (Func<A, Iterable<B>> bind, Func<A, B, C> project) Source #
Monadic bind (flatmap) of the sequence
type | B | Bound return value type |
param | bind | Bind function |
returns | Flat-mapped sequence |
method Iterable<B> SelectMany <B> (Func<A, IEnumerable<B>> bind) Source #
Monadic bind (flatmap) of the sequence
type | B | Bound return value type |
param | bind | Bind function |
returns | Flat-mapped sequence |
method Iterable<C> SelectMany <B, C> (Func<A, IEnumerable<B>> bind, Func<A, B, C> project) Source #
Monadic bind (flatmap) of the sequence
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
returns |
class IterableExtensions Source #
method Iterable<A> AsIterable <A> (this IEnumerable<A> xs) Source #
method Iterable<B> Choose <A, B> (this Iterable<A> list, Func<A, Option<B>> selector) Source #
Applies the given function 'selector' to each element of the sequence. Returns the sequence comprised of the results for each element where the function returns Some(f(x)).
type | A | sequence item type |
param | list | sequence |
param | selector | Selector function |
returns | Mapped and filtered sequence |
class IterableExtensions Source #
method Iterable<B> Map <A, B> (this Func<A, B> f, K<Iterable, A> ma) Source #
Functor map operation
Unwraps the value within the functor, passes it to the map function f
provided, and
then takes the mapped value and wraps it back up into a new functor.
param | ma | Functor to map |
param | f | Mapping function |
returns | Mapped functor |
method Iterable<B> Map <A, B> (this Func<A, B> f, Iterable<A> ma) Source #
Functor map operation
Unwraps the value within the functor, passes it to the map function f
provided, and
then takes the mapped value and wraps it back up into a new functor.
param | ma | Functor to map |
param | f | Mapping function |
returns | Mapped functor |
method Iterable<B> Action <A, B> (this K<Iterable, A> ma, K<Iterable, B> mb) Source #
Applicative action: runs the first applicative, ignores the result, and returns the second applicative
method Iterable<B> Action <A, B> (this Iterable<A> ma, K<Iterable, B> mb) Source #
Applicative action: runs the first applicative, ignores the result, and returns the second applicative
method Iterable<B> Apply <A, B> (this Iterable<Func<A, B>> mf, K<Iterable, A> ma) Source #
Applicative functor apply operation
Unwraps the value within the ma
applicative-functor, passes it to the unwrapped function(s) within mf
, and
then takes the resulting value and wraps it back up into a new applicative-functor.
param | ma | Value(s) applicative functor |
param | mf | Mapping function(s) |
returns | Mapped applicative functor |
method Iterable<B> Apply <A, B> (this K<Iterable, Func<A, B>> mf, K<Iterable, A> ma) Source #
Applicative functor apply operation
Unwraps the value within the ma
applicative-functor, passes it to the unwrapped function(s) within mf
, and
then takes the resulting value and wraps it back up into a new applicative-functor.
param | ma | Value(s) applicative functor |
param | mf | Mapping function(s) |
returns | Mapped applicative functor |
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.
type | A | Type of the values in the sequence |
method Iterable<A> create <A> (params A[] items) Source #
Create a sequence from a initial set of items
param | items | Items |
returns | sequence |
method Iterable<A> createRange <A> (ReadOnlySpan<A> items) Source #
Create a sequence from an initial set of items
param | items | Items |
returns | sequence |
method Iterable<A> createRange <A> (IEnumerable<A> items) Source #
Create a sequence from an initial set of items
param | items | Items |
returns | sequence |
method Iterable<A> generate <A> (int count, Func<int, A> generator) Source #
Generates a sequence of A using the provided delegate to initialise each item.
method Iterable<A> repeat <A> (A item, int count) Source #
Generates a sequence that contains one repeated value.
method Option<A> head <A> (Iterable<A> list) Source #
Get the item at the head (first) of the sequence or None if the sequence is empty
param | list | sequence |
returns | Optional head item |
method Iterable<B> choose <A, B> (Iterable<A> list, Func<A, Option<B>> selector) Source #
Applies the given function 'selector' to each element of the sequence. Returns the sequence comprised of the results for each element where the function returns Some(f(x)).
type | A | sequence item type |
param | list | sequence |
param | selector | Selector function |
returns | Mapped and filtered sequence |
method Iterable<A> rev <A> (Iterable<A> list) Source #
Reverses the sequence (Reverse in LINQ)
type | A | sequence item type |
param | list | sequence to reverse |
returns | Reversed sequence |
method Iterable<S> scan <S, A> (Iterable<A> list, S state, Func<S, A, S> folder) Source #
Applies a function to each element of the sequence, threading an accumulator argument through the computation. This function takes the state argument, and applies the function to it and the first element of the sequence. Then, it passes this result into the function along with the second element, and so on. Finally, it returns the list of intermediate results and the final result.
type | S | State type |
type | A | sequence item type |
param | list | sequence to fold |
param | state | Initial state |
param | folder | Folding function |
returns | Aggregate state |
method Iterable<S> scanBack <S, A> (Iterable<A> list, S state, Func<S, A, S> folder) Source #
Applies a function to each element of the sequence (from last element to first), threading an accumulator argument through the computation. This function takes the state argument, and applies the function to it and the first element of the sequence. Then, it passes this result into the function along with the second element, and so on. Finally, it returns the list of intermediate results and the final result.
type | S | State type |
type | A | Enumerable item type |
param | list | Enumerable to fold |
param | state | Initial state |
param | folder | Folding function |
returns | Aggregate state |
method Iterable<C> zip <A, B, C> (Iterable<A> list, Iterable<B> other, Func<A, B, C> zipper) Source #
Joins two sequences together either into a single sequence using the join function provided
param | list | First sequence to join |
param | other | Second sequence to join |
param | zipper | Join function |
returns | Joined sequence |
method Iterable<(A First, B Second)> zip <A, B> (Iterable<A> list, Iterable<B> other) Source #
Joins two sequences together either into an sequence of tuples
param | list | First sequence to join |
param | other | Second sequence to join |
param | zipper | Join function |
returns | Joined sequence of tuples |
method Iterable<A> distinct <A> (Iterable<A> list) Source #
Return a new sequence with all duplicate values removed
type | A | sequence item type |
param | list | sequence |
returns | A new sequence with all duplicate values removed |
method Iterable<A> distinct <EqA, A> (Iterable<A> list) Source #
Return a new sequence with all duplicate values removed
type | A | sequence item type |
param | list | sequence |
returns | A new sequence with all duplicate values removed |
method Iterable<A> take <A> (Iterable<A> list, int count) Source #
Returns a new sequence with the first 'count' items from the sequence provided
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> (Iterable<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
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> (Iterable<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.
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<B> map <A, B> (Func<A, B> f, K<Iterable, A> ma) Source #
Functor map operation
Unwraps the value within the functor, passes it to the map function f
provided, and
then takes the mapped value and wraps it back up into a new functor.
param | ma | Functor to map |
param | f | Mapping function |
returns | Mapped functor |
method Iterable<B> action <A, B> (K<Iterable, A> ma, K<Iterable, B> mb) Source #
Applicative action: runs the first applicative, ignores the result, and returns the second applicative
method Iterable<B> apply <A, B> (K<Iterable, Func<A, B>> mf, K<Iterable, A> ma) Source #
Applicative functor apply operation
Unwraps the value within the ma
applicative-functor, passes it to the unwrapped function(s) within mf
, and
then takes the resulting value and wraps it back up into a new applicative-functor.
param | ma | Value(s) applicative functor |
param | mf | Mapping function(s) |
returns | Mapped applicative functor |