- ListInfo
- Lst <A>
- Empty
- Lst (IEnumerable<A> initial)
- Lst (ReadOnlySpan<A> initial)
- IsEmpty
- Case
- head
- headOrNone
- tail
- tailOrNone
- item (int index)
- itemOrNone (int index)
- map <B> (Lens<A, B> lens)
- this []
- At (int index)
- Count
- AsStream <M> ()
- Contains (A value)
- Contains <EqA> (A value)
- Add (A value)
- AddRange (IEnumerable<A> items)
- Clear ()
- GetEnumerator ()
- IndexOf (A item, int index = 0, int count = -1, IEqualityComparer<A>? equalityComparer = null)
- Insert (int index, A value)
- InsertRange (int index, IEnumerable<A> items)
- LastIndexOf (A item, int index = 0, int count = -1, IEqualityComparer<A>? equalityComparer = null)
- Remove (A value)
- Remove (A value, IEqualityComparer<A> equalityComparer)
- RemoveAll (Func<A, bool> pred)
- RemoveAt (int index)
- RemoveRange (int index, int count)
- SetItem (int index, A value)
- FindRange (int index, int count)
- ToSeq ()
- ToString ()
- ToFullString (string separator = ", ")
- ToFullArrayString (string separator = ", ")
- AsIterable ()
- Skip (int amount)
- Reverse ()
- Do (Action<A> f)
- Map <U> (Func<A, U> map)
- Traverse <F, B> (Func<A, K<F, B>> f)
- TraverseM <M, B> (Func<A, K<M, B>> f)
- Filter (Func<A, bool> pred)
- + (Lst<A> lhs, A rhs)
- + (A lhs, Lst<A> rhs)
- + (Lst<A> lhs, Lst<A> rhs)
- | (Lst<A> x, K<Lst, A> y)
- | (K<Lst, A> x, Lst<A> y)
- Combine (Lst<A> rhs)
- - (Lst<A> lhs, Lst<A> rhs)
- Subtract (Lst<A> rhs)
- Equals (object? obj)
- GetHashCode ()
- CompareTo (object? obj)
- Equals (Lst<A> other)
- == (Lst<A> lhs, Lst<A> rhs)
- != (Lst<A> lhs, Lst<A> rhs)
- < (Lst<A> lhs, Lst<A> rhs)
- <= (Lst<A> lhs, Lst<A> rhs)
- > (Lst<A> lhs, Lst<A> rhs)
- >= (Lst<A> lhs, Lst<A> rhs)
- ToArr ()
- CompareTo (Lst<A> other)
- AdditiveIdentity
- LstExtensions
- As <A> (this K<Lst, A> xs)
- HeadAndTail <A> (this IEnumerable<A> ma)
- HeadAndTailSafe <A> (this IEnumerable<A> ma)
- Flatten <A> (this Lst<Lst<A>> ma)
- Flatten <A> (this IEnumerable<IEnumerable<A>> ma)
- Match <A, B> (this IEnumerable<A> list, Func<B> Empty, Func<Seq<A>, B> More)
- Match <A, B> (this IEnumerable<A> list, Func<B> Empty, Func<A, Seq<A>, B> More)
- Match <T, R> (this IEnumerable<T> list, Func<R> Empty, Func<T, R> One, Func<T, Seq<T>, R> More )
- Init <A> (this IEnumerable<A> list)
- Tail <T> (this IEnumerable<T> list)
- Intersperse <A> (this IEnumerable<A> ma, A value)
- Concat (this IEnumerable<string> xs)
- Rev <A> (this Lst<A> list)
- Reduce <T> (this IEnumerable<T> list, Func<T, T, T> reducer)
- ReduceBack <T> (this IEnumerable<T> list, Func<T, T, T> reducer)
- Scan <S, T> (this IEnumerable<T> list, S state, Func<S, T, S> folder)
- ScanBack <S, T> (this IEnumerable<T> list, S state, Func<S, T, S> folder)
- Consume <T> (this IEnumerable<T> list)
- Distinct <EQ, T> (this IEnumerable<T> list)
- Tails <T> (this IEnumerable<T> self)
- Span <T> (this IEnumerable<T> self, Func<T, bool> pred)
- Bind <T, R> (this IEnumerable<T> self, Func<T, IEnumerable<R>> binder)
- Select <A, B> (this Lst<A> self, Func<A, B> map)
- BindEnumerable <A, B> (this Lst<A> self, Func<A, Lst<B>> binder)
- Bind <A, B> (this Lst<A> self, Func<A, Lst<B>> binder)
- Bind <A, B> (this Lst<A> self, Func<A, K<Lst, B>> binder)
- Count <A> (this Lst<A> self)
- SelectMany <A, B, C> (this Lst<A> self, Func<A, Lst<B>> bind, Func<A, B, C> project)
- SkipLast <T> (this IEnumerable<T> self)
- SkipLast <T> (this IEnumerable<T> self, int n)
- ToOption <A> (this IEnumerable<A> self)
- AsQueryable <A> (this Lst<A> source)
- LstExtensions
- Map <A, B> (this Func<A, B> f, K<Lst, A> ma)
- Map <A, B> (this Func<A, B> f, Lst<A> ma)
- Action <A, B> (this Lst<A> ma, K<Lst, B> mb)
- Action <A, B> (this K<Lst, A> ma, K<Lst, B> mb)
- Apply <A, B> (this Lst<Func<A, B>> mf, K<Lst, A> ma)
- Apply <A, B> (this K<Lst, Func<A, B>> mf, K<Lst, A> ma)
- ListEnumerator <T>
- List
- flatten <A> (Lst<Lst<A>> ma)
- flatten <A> (IEnumerable<IEnumerable<A>> ma)
- empty <T> ()
- singleton <A> (A value)
- create <T> ()
- create <T> (params T[] items)
- createRange <T> (IEnumerable<T> items)
- createRange <A> (ReadOnlySpan<A> items)
- generate <T> (int count, Func<int, T> generator)
- generate <T> (Func<int, T> generator)
- repeat <T> (T item, int count)
- add <T> (Lst<T> list, T value)
- addRange <T> (Lst<T> list, IEnumerable<T> value)
- remove <T> (Lst<T> list, T value)
- removeAt <T> (Lst<T> list, int index)
- head <T> (IEnumerable<T> list)
- headOrNone <A> (IEnumerable<A> list)
- headOrLeft <L, R> (IEnumerable<R> list, L left)
- headOrInvalid <Fail, Success> (IEnumerable<Success> list, Fail fail)
- headOrInvalid <Fail, Success> (IEnumerable<Success> list)
- last <A> (IEnumerable<A> list)
- lastOrNone <A> (IEnumerable<A> list)
- lastOrLeft <L, R> (IEnumerable<R> list, L left)
- lastOrInvalid <Fail, Success> (IEnumerable<Success> list, Fail fail)
- lastOrInvalid <Fail, Success> (IEnumerable<Success> list)
- init <A> (IEnumerable<A> list)
- tail <T> (IEnumerable<T> list)
- map <T, R> (IEnumerable<T> list, Func<T, R> map)
- map <T, R> (IEnumerable<T> list, Func<int, T, R> map)
- filter <T> (IEnumerable<T> list, Func<T, bool> predicate)
- choose <T, R> (IEnumerable<T> list, Func<T, Option<R>> selector)
- choose <T, R> (IEnumerable<T> list, Func<int, T, Option<R>> selector)
- collect <T, R> (IEnumerable<T> list, Func<T, IEnumerable<R>> map)
- sum (IEnumerable<int> list)
- sum (IEnumerable<float> list)
- sum (IEnumerable<double> list)
- sum (IEnumerable<decimal> list)
- rev <T> (IEnumerable<T> list)
- rev <T> (Lst<T> list)
- append <T> (IEnumerable<T> lhs, IEnumerable<T> rhs)
- append <T> (IEnumerable<T> x, IEnumerable<IEnumerable<T>> xs)
- append <T> (params IEnumerable<T>[] lists)
- fold <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder)
- foldBack <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder)
- foldWhile <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder, Func<T, bool> preditem)
- foldWhile <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder, Func<S, bool> predstate)
- foldBackWhile <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder, Func<T, bool> preditem)
- foldBackWhile <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder, Func<S, bool> predstate)
- foldUntil <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder, Func<T, bool> preditem)
- foldUntil <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder, Func<S, bool> predstate)
- foldBackUntil <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder, Func<T, bool> preditem)
- foldBackUntil <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder, Func<S, bool> predstate)
- reduce <A> (IEnumerable<A> list, Func<A, A, A> reducer)
- reduceOrNone <A> (IEnumerable<A> list, Func<A, A, A> reducer)
- reduceBack <A> (IEnumerable<A> list, Func<A, A, A> reducer)
- reduceBackOrNone <A> (IEnumerable<A> list, Func<A, A, A> reducer)
- scan <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder)
- scanBack <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder)
- find <T> (IEnumerable<T> list, Func<T, bool> pred)
- findSeq <T> (IEnumerable<T> list, Func<T, bool> pred)
- freeze <T> (IEnumerable<T> list)
- zip <T, U, V> (IEnumerable<T> list, IEnumerable<U> other, Func<T, U, V> zipper)
- zip <T, U> (IEnumerable<T> list, IEnumerable<U> other)
- length <T> (IEnumerable<T> list)
- iter <T> (IEnumerable<T> list, Action<T> action)
- iter <T> (IEnumerable<T> list, Action<int, T> action)
- consume <T> (IEnumerable<T> list)
- forall <T> (IEnumerable<T> list, Func<T, bool> pred)
- distinct <T> (IEnumerable<T> list)
- distinct <EQ, T> (IEnumerable<T> list)
- distinct <T, K> (IEnumerable<T> list, Func<T, K> keySelector, Option<Func<K, K, bool>> compare = default)
- take <T> (IEnumerable<T> list, int count)
- takeWhile <T> (IEnumerable<T> list, Func<T, bool> pred)
- takeWhile <T> (IEnumerable<T> list, Func<T, int, bool> pred)
- unfold <S> (S state, Func<S, Option<S>> unfolder)
- unfold <S, A> (S state, Func<S, Option<(A, S)>> unfolder)
- unfold <S1, S2, A> ((S1, S2) state, Func<S1, S2, Option<(A, S1, S2)>> unfolder)
- unfold <S1, S2, S3, A> ((S1, S2, S3) state, Func<S1, S2, S3, Option<(A, S1, S2, S3)>> unfolder)
- unfold <S1, S2, S3, S4, A> ((S1, S2, S3, S4) state, Func<S1, S2, S3, S4, Option<(A, S1, S2, S3, S4)>> unfolder)
- exists <T> (IEnumerable<T> list, Func<T, bool> pred)
- headSafe <T> (IEnumerable<T> list)
- tails <T> (IEnumerable<T> self)
- span <T> (IEnumerable<T> self, Func<T, bool> pred)
- Lst
- Prelude
Immutable list
type | A | Value type |
property object? Case Source #
Reference version for use in pattern-matching
Empty collection = null
Singleton collection = A
More = (A, Seq〈A〉) -- head and tail
Example:
var res = list.Case switch
{
A value => ...,
(var x, var xs) => ...,
_ => ...
}
property Lens<Lst<A>, Option<A>> headOrNone Source #
Head or none lens
property Lens<Lst<A>, Option<A>> tailOrNone Source #
Tail or none lens
property Lst<A> AdditiveIdentity Source #
method Lens<Lst<A>, Option<A>> itemOrNone (int index) Source #
Item or none at index lens
method bool Contains (A value) Source #
Find if a value is in the collection
param | value | Value to test |
returns | True if collection contains value |
method bool Contains <EqA> (A value) Source #
Contains with provided Eq class instance
type | EqA | Eq class instance |
param | value | Value to test |
returns | True if collection contains value |
method ListEnumerator<A> GetEnumerator () Source #
Get enumerator
method int IndexOf (A item, int index = 0, int count = -1, IEqualityComparer<A>? equalityComparer = null) Source #
Find the index of an item
method Lst<A> InsertRange (int index, IEnumerable<A> items) Source #
Insert range of values at specified index
method int LastIndexOf (A item, int index = 0, int count = -1, IEqualityComparer<A>? equalityComparer = null) Source #
Find the last index of an item in the list
method Lst<A> Remove (A value, IEqualityComparer<A> equalityComparer) Source #
Remove all items that match the value from the list
method Lst<A> RemoveRange (int index, int count) Source #
Remove a range of items
method Iterable<A> FindRange (int index, int count) Source #
Returns an enumerable range from the collection. This is the fastest way of iterating sub-ranges of the collection.
param | index | Index into the collection |
param | count | Number of items to find |
returns | IEnumerable of items |
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> AsIterable () Source #
method Lst<A> Do (Action<A> f) Source #
Impure iteration of the bound values in the structure
returns | Returns the original unmodified structure |
method K<F, Lst<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, Lst<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 int GetHashCode () Source #
Get the hash code Lazily (and once only) calculates the hash from the elements in the list Empty list hash == 0
class LstExtensions Source #
method (A Head, IEnumerable<A> Tail) HeadAndTail <A> (this IEnumerable<A> ma) Source #
Accesses the head of an enumerable and yields the remainder without multiple-enumerations
method Option<(A Head, IEnumerable<A> Tail)> HeadAndTailSafe <A> (this IEnumerable<A> ma) Source #
Accesses the head of an enumerable and yields the remainder without multiple-enumerations
method B Match <A, B> (this IEnumerable<A> list, Func<B> Empty, Func<Seq<A>, B> More) Source #
Match empty list, or multi-item list
type | B | Return value type |
param | Empty | Match for an empty list |
param | More | Match for a non-empty |
returns | Result of match function invoked |
method B Match <A, B> (this IEnumerable<A> list, Func<B> Empty, Func<A, Seq<A>, B> More) Source #
List pattern matching
method R Match <T, R> (this IEnumerable<T> list, Func<R> Empty, Func<T, R> One, Func<T, Seq<T>, R> More ) Source #
List pattern matching
method IEnumerable<A> Init <A> (this IEnumerable<A> list) Source #
Get all items in the list except the last one
Must evaluate the last item to know it's the last, but won't return it
param | list | List |
returns | The initial items (all but the last) |
method Iterable<T> Tail <T> (this IEnumerable<T> list) Source #
Get the tail of the list (skips the head item)
param | list | List |
returns | Enumerable of T |
method IEnumerable<A> Intersperse <A> (this IEnumerable<A> ma, A value) Source #
Inject a value in between each item in the enumerable
type | A | Bound type |
param | ma | Enumerable to inject values into |
param | value | Item to inject |
returns | An enumerable with the values injected |
method Lst<A> Rev <A> (this Lst<A> list) Source #
Reverses the list (Reverse in LINQ)
type | A | List item type |
param | list | Listto reverse |
returns | Reversed list |
method T Reduce <T> (this IEnumerable<T> list, Func<T, T, T> reducer) Source #
Applies a function to each element of the collection (from last element to first), threading an accumulator argument through the computation. This function first applies the function to the first two elements of the list. Then, it passes this result into the function along with the third element and so on. Finally, it returns the final result.
type | T | Enumerable item type |
param | list | Enumerable to reduce |
param | reducer | Reduce function |
returns | Aggregate value |
method T ReduceBack <T> (this IEnumerable<T> list, Func<T, T, T> reducer) Source #
Applies a function to each element of the collection, threading an accumulator argument through the computation. This function first applies the function to the first two elements of the list. Then, it passes this result into the function along with the third element and so on. Finally, it returns the final result.
type | T | Enumerable item type |
param | list | Enumerable to reduce |
param | reducer | Reduce function |
returns | Aggregate value |
method IEnumerable<S> Scan <S, T> (this IEnumerable<T> list, S state, Func<S, T, S> folder) Source #
Applies a function to each element of the collection, 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 list. 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 | Enumerable item type |
param | list | Enumerable to fold |
param | state | Initial state |
param | folder | Folding function |
returns | Aggregate state |
method IEnumerable<S> ScanBack <S, T> (this IEnumerable<T> list, S state, Func<S, T, S> folder) Source #
Applies a function to each element of the collection (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 list. 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 | Enumerable item type |
param | list | Enumerable to fold |
param | state | Initial state |
param | folder | Folding function |
returns | Aggregate state |
method Unit Consume <T> (this IEnumerable<T> list) Source #
Iterate each item in the enumerable in order (consume items)
type | T | Enumerable item type |
param | list | Enumerable to consume |
returns | Unit |
method IEnumerable<T> Distinct <EQ, T> (this IEnumerable<T> list) Source #
Return a new enumerable with all duplicate values removed
type | T | Enumerable item type |
param | list | Enumerable |
returns | A new enumerable with all duplicate values removed |
method IEnumerable<IEnumerable<T>> Tails <T> (this IEnumerable<T> self) Source #
The tails function returns all final segments of the argument, longest first. For example, i.e. tails(['a','b','c']) == [['a','b','c'], ['b','c'], ['c'],[]]
type | T | List item type |
param | self | List |
returns | Enumerable of Enumerables of T |
method (IEnumerable<T>, IEnumerable<T>) Span <T> (this IEnumerable<T> self, Func<T, bool> pred) Source #
Span, applied to a predicate 'pred' and a list, returns a tuple where first element is longest prefix (possibly empty) of elements that satisfy 'pred' and second element is the remainder of the list:
type | T | List element type |
param | self | List |
param | pred | Predicate |
returns | Split list |
List.span(List(1,2,3,4,1,2,3,4), x => x 〈 3) == (List(1,2),List(3,4,1,2,3,4))
List.span(List(1,2,3), x => x 〈 9) == (List(1,2,3),List())
List.span(List(1,2,3), x => x 〈 0) == (List(),List(1,2,3))
method IEnumerable<R> Bind <T, R> (this IEnumerable<T> self, Func<T, IEnumerable<R>> binder) Source #
Monadic bind function for IEnumerable
method Lst<B> Select <A, B> (this Lst<A> self, Func<A, B> map) Source #
LINQ Select implementation for Lst
method IEnumerable<B> BindEnumerable <A, B> (this Lst<A> self, Func<A, Lst<B>> binder) Source #
Monadic bind function for Lst that returns an IEnumerable
method Lst<B> Bind <A, B> (this Lst<A> self, Func<A, K<Lst, B>> binder) Source #
Monadic bind function
method int Count <A> (this Lst<A> self) Source #
Returns the number of items in the Lst T
type | A | Item type |
param | list | List to count |
returns | The number of items in the list |
method Lst<C> SelectMany <A, B, C> (this Lst<A> self, Func<A, Lst<B>> bind, Func<A, B, C> project) Source #
LINQ bind implementation for Lst
method IEnumerable<T> SkipLast <T> (this IEnumerable<T> self) Source #
Take all but the last item in an enumerable
type | T | Bound value type |
method IEnumerable<T> SkipLast <T> (this IEnumerable<T> self, int n) Source #
Take all but the last n items in an enumerable
type | T | Bound value type |
method Option<A> ToOption <A> (this IEnumerable<A> self) Source #
Convert the enumerable to an Option.
type | A | Bound value type |
param | self | This |
returns | If enumerable is empty then return None, else Some(head) |
method IQueryable<A> AsQueryable <A> (this Lst<A> source) Source #
Convert to a queryable
class LstExtensions Source #
method Lst<B> Map <A, B> (this Func<A, B> f, K<Lst, 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 Lst<B> Map <A, B> (this Func<A, B> f, Lst<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 Lst<B> Action <A, B> (this Lst<A> ma, K<Lst, B> mb) Source #
Applicative action: runs the first applicative, ignores the result, and returns the second applicative
method Lst<B> Action <A, B> (this K<Lst, A> ma, K<Lst, B> mb) Source #
Applicative action: runs the first applicative, ignores the result, and returns the second applicative
method Lst<B> Apply <A, B> (this Lst<Func<A, B>> mf, K<Lst, 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 Lst<B> Apply <A, B> (this K<Lst, Func<A, B>> mf, K<Lst, 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 |
struct ListEnumerator <T> Source #
method Lst<A> singleton <A> (A value) Source #
Create a singleton collection
param | value | Single value |
returns | Collection with a single item in it |
method Lst<T> create <T> (params T[] items) Source #
Create a list from a initial set of items
param | items | Items |
returns | Lst T |
method Lst<T> createRange <T> (IEnumerable<T> items) Source #
Create a list from an initial set of items
param | items | Items |
returns | Lst T |
method Lst<A> createRange <A> (ReadOnlySpan<A> items) Source #
Create a list from an initial set of items
param | items | Items |
returns | Lst T |
method Iterable<T> generate <T> (int count, Func<int, T> generator) Source #
Generates a sequence of T using the provided delegate to initialise each item.
method Iterable<T> generate <T> (Func<int, T> generator) Source #
Generates an int.MaxValue sequence of T using the provided delegate to initialise each item.
method Iterable<T> repeat <T> (T item, int count) Source #
Generates a sequence that contains one repeated value.
method Lst<T> add <T> (Lst<T> list, T value) Source #
Add an item to the list
param | list | List |
param | value | Item to add |
returns | A new Lst T |
method Lst<T> addRange <T> (Lst<T> list, IEnumerable<T> value) Source #
Add a range of items to the list
param | list | List |
param | value | Items to add |
returns | A new Lst T |
method Lst<T> remove <T> (Lst<T> list, T value) Source #
Remove an item from the list
param | list | List |
param | value | value to remove |
returns | A new Lst T |
method Lst<T> removeAt <T> (Lst<T> list, int index) Source #
Remove an item at a specified index in the list
param | list | List |
param | index | Index of item to remove |
returns | A new Lst T |
method T head <T> (IEnumerable<T> list) Source #
Get the item at the head (first) of the list
param | list | List |
returns | Head item |
method Option<A> headOrNone <A> (IEnumerable<A> list) Source #
Get the item at the head (first) of the list or None if the list is empty
param | list | List |
returns | Optional head item |
method Either<L, R> headOrLeft <L, R> (IEnumerable<R> list, L left) Source #
Get the item at the head (first) of the list or Left if the list is empty
param | list | List |
returns | Either head item or left |
method Validation<Fail, Success> headOrInvalid <Fail, Success> (IEnumerable<Success> list, Fail fail) Source #
Get the item at the head (first) of the list or fail if the list is empty
param | list | List |
returns | Either head item or fail |
method Validation<Fail, Success> headOrInvalid <Fail, Success> (IEnumerable<Success> list) Source #
Get the item at the head (first) of the list or fail if the list is empty
param | list | List |
returns | Either head item or fail |
method A last <A> (IEnumerable<A> list) Source #
Get the last item of the list
param | list | List |
returns | Last item |
method Option<A> lastOrNone <A> (IEnumerable<A> list) Source #
Get the last item of the list
param | list | List |
returns | Last item |
method Either<L, R> lastOrLeft <L, R> (IEnumerable<R> list, L left) Source #
Get the last item of the list
param | list | List |
returns | Last item |
method Validation<Fail, Success> lastOrInvalid <Fail, Success> (IEnumerable<Success> list, Fail fail) Source #
Get the last item of the list
param | list | List |
returns | Last item |
method Validation<Fail, Success> lastOrInvalid <Fail, Success> (IEnumerable<Success> list) Source #
Get the last item of the list
param | list | List |
returns | Last item |
method Seq<A> init <A> (IEnumerable<A> list) Source #
Get all items in the list except the last one
Must evaluate the last item to know it's the last, but won't return it
param | list | List |
returns | The initial items (all but the last) |
method Iterable<T> tail <T> (IEnumerable<T> list) Source #
Get the tail of the list (skips the head item)
param | list | List |
returns | Enumerable of T |
method Iterable<R> map <T, R> (IEnumerable<T> list, Func<T, R> map) Source #
Projects the values in the enumerable using a map function into a new enumerable (Select in LINQ).
type | T | Enumerable item type |
type | R | Return enumerable item type |
param | list | Enumerable to map |
param | map | Map function |
returns | Mapped enumerable |
method Iterable<R> map <T, R> (IEnumerable<T> list, Func<int, T, R> map) Source #
Projects the values in the enumerable into a new enumerable using a map function, which is also given an index value (Select in LINQ - note that the order of the arguments of the map function are the other way around, here the index is the first argument).
type | T | Enumerable item type |
type | R | Return enumerable item type |
param | list | Enumerable to map |
param | map | Map function |
returns | Mapped enumerable |
method Iterable<T> filter <T> (IEnumerable<T> list, Func<T, bool> predicate) Source #
Removes items from the list that do not match the given predicate (Where in LINQ)
type | T | Enumerable item type |
param | list | Enumerable to filter |
param | predicate | Predicate function |
returns | Filtered enumerable |
method Iterable<R> choose <T, R> (IEnumerable<T> list, Func<T, Option<R>> selector) Source #
Applies the given function 'selector' to each element of the list. Returns the list comprised of the results for each element where the function returns Some(f(x)).
type | T | Enumerable item type |
param | list | Enumerable |
param | selector | Selector function |
returns | Mapped and filtered enumerable |
method Iterable<R> choose <T, R> (IEnumerable<T> list, Func<int, T, Option<R>> selector) Source #
Applies the given function 'selector' to each element of the list. Returns the list comprised of the results for each element where the function returns Some(f(x)). An index value is passed through to the selector function also.
type | T | Enumerable item type |
param | list | Enumerable |
param | selector | Selector function |
returns | Mapped and filtered enumerable |
method Iterable<R> collect <T, R> (IEnumerable<T> list, Func<T, IEnumerable<R>> map) Source #
For each element of the list, applies the given function. Concatenates all the results and returns the combined list.
type | T | Enumerable item type |
type | R | Return enumerable item type |
param | list | Enumerable to map |
param | map | Map function |
returns | Mapped enumerable |
method int sum (IEnumerable<int> list) Source #
Returns the sum total of all the items in the list (Sum in LINQ)
param | list | List to sum |
returns | Sum total |
method float sum (IEnumerable<float> list) Source #
Returns the sum total of all the items in the list (Sum in LINQ)
param | list | List to sum |
returns | Sum total |
method double sum (IEnumerable<double> list) Source #
Returns the sum total of all the items in the list (Sum in LINQ)
param | list | List to sum |
returns | Sum total |
method decimal sum (IEnumerable<decimal> list) Source #
Returns the sum total of all the items in the list (Sum in LINQ)
param | list | List to sum |
returns | Sum total |
method Iterable<T> rev <T> (IEnumerable<T> list) Source #
Reverses the enumerable (Reverse in LINQ)
type | T | Enumerable item type |
param | list | Enumerable to reverse |
returns | Reversed enumerable |
method Lst<T> rev <T> (Lst<T> list) Source #
Reverses the list (Reverse in LINQ)
type | T | List item type |
param | list | List to reverse |
returns | Reversed list |
method Iterable<T> append <T> (IEnumerable<T> lhs, IEnumerable<T> rhs) Source #
Concatenate two enumerables (Concat in LINQ)
type | T | Enumerable item type |
param | lhs | First enumerable |
param | rhs | Second enumerable |
returns | Concatenated enumerable |
method Iterable<T> append <T> (IEnumerable<T> x, IEnumerable<IEnumerable<T>> xs) Source #
Concatenate an enumerable and an enumerable of enumerables
type | T | List item type |
param | lhs | First list |
param | rhs | Second list |
returns | Concatenated list |
method Iterable<T> append <T> (params IEnumerable<T>[] lists) Source #
Concatenate N enumerables
type | T | Enumerable type |
param | lists | Enumerables to concatenate |
returns | A single enumerable with all of the items concatenated |
method S fold <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder) Source #
Applies a function 'folder' to each element of the collection, threading an accumulator argument through the computation. The fold function takes the state argument, and applies the function 'folder' to it and the first element of the list. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result. (Aggregate in LINQ)
type | S | State type |
type | T | Enumerable item type |
param | list | Enumerable to fold |
param | state | Initial state |
param | folder | Fold function |
returns | Aggregate value |
method S foldBack <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder) Source #
Applies a function 'folder' to each element of the collection (from last element to first), threading an aggregate state through the computation. The fold function takes the state argument, and applies the function 'folder' to it and the first element of the list. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result.
type | S | State type |
type | T | Enumerable item type |
param | list | Enumerable to fold |
param | state | Initial state |
param | folder | Fold function |
returns | Aggregate value |
method S foldWhile <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder, Func<T, bool> preditem) Source #
Applies a function 'folder' to each element of the collection whilst the predicate function returns True for the item being processed, threading an aggregate state through the computation. The fold function takes the state argument, and applies the function 'folder' to it and the first element of the list. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result.
type | S | State type |
type | T | Enumerable item type |
param | list | Enumerable to fold |
param | state | Initial state |
param | folder | Fold function |
param | preditem | Predicate function |
returns | Aggregate value |
method S foldWhile <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder, Func<S, bool> predstate) Source #
Applies a function 'folder' to each element of the collection, threading an accumulator argument through the computation (and whilst the predicate function returns True when passed the aggregate state). The fold function takes the state argument, and applies the function 'folder' to it and the first element of the list. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result.
type | S | State type |
type | T | Enumerable item type |
param | list | Enumerable to fold |
param | state | Initial state |
param | folder | Fold function |
param | predstate | Predicate function |
returns | Aggregate value |
method S foldBackWhile <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder, Func<T, bool> preditem) Source #
Applies a function 'folder' to each element of the collection (from last element to first) whilst the predicate function returns True for the item being processed, threading an aggregate state through the computation. The fold function takes the state argument, and applies the function 'folder' to it and the first element of the list. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result.
type | S | State type |
type | T | Enumerable item type |
param | list | Enumerable to fold |
param | state | Initial state |
param | folder | Fold function |
param | preditem | Predicate function |
returns | Aggregate value |
method S foldBackWhile <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder, Func<S, bool> predstate) Source #
Applies a function 'folder' to each element of the collection (from last element to first), threading an accumulator argument through the computation (and whilst the predicate function returns True when passed the aggregate state). The fold function takes the state argument, and applies the function 'folder' to it and the first element of the list. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result.
type | S | State type |
type | T | Enumerable item type |
param | list | Enumerable to fold |
param | state | Initial state |
param | folder | Fold function |
param | predstate | Predicate function |
returns | Aggregate value |
method S foldUntil <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder, Func<T, bool> preditem) Source #
Applies a function 'folder' to each element of the collection whilst the predicate function returns False for the item being processed, threading an aggregate state through the computation. The fold function takes the state argument, and applies the function 'folder' to it and the first element of the list. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result.
type | S | State type |
type | T | Enumerable item type |
param | list | Enumerable to fold |
param | state | Initial state |
param | folder | Fold function |
param | preditem | Predicate function |
returns | Aggregate value |
method S foldUntil <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder, Func<S, bool> predstate) Source #
Applies a function 'folder' to each element of the collection, threading an accumulator argument through the computation (and whilst the predicate function returns False when passed the aggregate state). The fold function takes the state argument, and applies the function 'folder' to it and the first element of the list. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result.
type | S | State type |
type | T | Enumerable item type |
param | list | Enumerable to fold |
param | state | Initial state |
param | folder | Fold function |
param | predstate | Predicate function |
returns | Aggregate value |
method S foldBackUntil <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder, Func<T, bool> preditem) Source #
Applies a function 'folder' to each element of the collection (from last element to first) whilst the predicate function returns False for the item being processed, threading an aggregate state through the computation. The fold function takes the state argument, and applies the function 'folder' to it and the first element of the list. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result.
type | S | State type |
type | T | Enumerable item type |
param | list | Enumerable to fold |
param | state | Initial state |
param | folder | Fold function |
param | preditem | Predicate function |
returns | Aggregate value |
method S foldBackUntil <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder, Func<S, bool> predstate) Source #
Applies a function 'folder' to each element of the collection (from last element to first), threading an accumulator argument through the computation (and whilst the predicate function returns False when passed the aggregate state). The fold function takes the state argument, and applies the function 'folder' to it and the first element of the list. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result.
type | S | State type |
type | T | Enumerable item type |
param | list | Enumerable to fold |
param | state | Initial state |
param | folder | Fold function |
param | predstate | Predicate function |
returns | Aggregate value |
method A reduce <A> (IEnumerable<A> list, Func<A, A, A> reducer) Source #
Applies a function to each element of the collection (from first element to last), threading an accumulator argument through the computation. This function first applies the function to the first two elements of the list. Then, it passes this result into the function along with the third element and so on. Finally, it returns the final result.
The enumerable must contain at least one item or an excpetion will be thrown
type | A | Bound item type |
param | list | Enumerable to reduce |
param | reducer | Reduce function |
returns | Aggregate value |
method Option<A> reduceOrNone <A> (IEnumerable<A> list, Func<A, A, A> reducer) Source #
Applies a function to each element of the collection (from first element to last), threading an accumulator argument through the computation. This function first applies the function to the first two elements of the list. Then, it passes this result into the function along with the third element and so on. Finally, it returns the final result.
The enumerable must contain at least one item or None will be returned
type | A | Bound item type |
param | list | Enumerable to reduce |
param | reducer | Reduce function |
returns | Optional aggregate value |
method A reduceBack <A> (IEnumerable<A> list, Func<A, A, A> reducer) Source #
Applies a function to each element of the collection, threading an accumulator argument through the computation. This function first applies the function to the first two elements of the list. Then, it passes this result into the function along with the third element and so on. Finally, it returns the final result.
The enumerable must contain at least one item or an excpetion will be thrown
type | A | Bound item type |
param | list | Enumerable to reduce |
param | reducer | Reduce function |
returns | Aggregate value |
method Option<A> reduceBackOrNone <A> (IEnumerable<A> list, Func<A, A, A> reducer) Source #
Applies a function to each element of the collection, threading an accumulator argument through the computation. This function first applies the function to the first two elements of the list. Then, it passes this result into the function along with the third element and so on. Finally, it returns the final result.
The enumerable must contain at least one item or None will be returned
type | A | Bound item type |
param | list | Enumerable to reduce |
param | reducer | Reduce function |
returns | Optional aggregate value |
method IEnumerable<S> scan <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder) Source #
Applies a function to each element of the collection, 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 list. 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 | Enumerable item type |
param | list | Enumerable to fold |
param | state | Initial state |
param | folder | Folding function |
returns | Aggregate state |
method IEnumerable<S> scanBack <S, T> (IEnumerable<T> list, S state, Func<S, T, S> folder) Source #
Applies a function to each element of the collection (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 list. 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 | Enumerable item type |
param | list | Enumerable to fold |
param | state | Initial state |
param | folder | Folding function |
returns | Aggregate state |
method Option<T> find <T> (IEnumerable<T> list, Func<T, bool> pred) Source #
Returns Some(x) for the first item in the list that matches the predicate provided, None otherwise.
type | T | Enumerable item type |
param | list | Enumerable to search |
param | pred | Predicate |
returns | Some(x) for the first item in the list that matches the predicate provided, None otherwise. |
method IEnumerable<T> findSeq <T> (IEnumerable<T> list, Func<T, bool> pred) Source #
Returns [x] for the first item in the list that matches the predicate provided, [] otherwise.
type | T | Enumerable item type |
param | list | Enumerable to search |
param | pred | Predicate |
returns | [x] for the first item in the list that matches the predicate provided, [] otherwise. |
method Lst<T> freeze <T> (IEnumerable<T> list) Source #
Convert any enumerable into an immutable Lst T
type | T | Enumerable item type |
param | list | Enumerable to convert |
returns | Lst of T |
method IEnumerable<V> zip <T, U, V> (IEnumerable<T> list, IEnumerable<U> other, Func<T, U, V> zipper) Source #
Joins two enumerables together either into a single enumerable using the join function provided
param | list | First list to join |
param | other | Second list to join |
param | zipper | Join function |
returns | Joined enumerable |
method IEnumerable<(T First, U Second)> zip <T, U> (IEnumerable<T> list, IEnumerable<U> other) Source #
Joins two enumerables together either into an enumerables of tuples
param | list | First list to join |
param | other | Second list to join |
param | zipper | Join function |
returns | Joined enumerable of tuples |
method int length <T> (IEnumerable<T> list) Source #
Returns the number of items in the enumerable
type | T | Enumerable item type |
param | list | Enumerable to count |
returns | The number of items in the enumerable |
method Unit iter <T> (IEnumerable<T> list, Action<T> action) Source #
Invokes an action for each item in the enumerable in order
type | T | Enumerable item type |
param | list | Enumerable to iterate |
param | action | Action to invoke with each item |
returns | Unit |
method Unit iter <T> (IEnumerable<T> list, Action<int, T> action) Source #
Invokes an action for each item in the enumerable in order and supplies a running index value.
type | T | Enumerable item type |
param | list | Enumerable to iterate |
param | action | Action to invoke with each item |
returns | Unit |
method Unit consume <T> (IEnumerable<T> list) Source #
Iterate each item in the enumerable in order (consume items)
type | T | Enumerable item type |
param | list | Enumerable to consume |
returns | Unit |
method bool forall <T> (IEnumerable<T> list, Func<T, bool> pred) Source #
Returns true if all items in the enumerable match a predicate (Any in LINQ)
type | T | Enumerable item type |
param | list | Enumerable to test |
param | pred | Predicate |
returns | True if all items in the enumerable match the predicate |
method IEnumerable<T> distinct <T> (IEnumerable<T> list) Source #
Return a new enumerable with all duplicate values removed
type | T | Enumerable item type |
param | list | Enumerable |
returns | A new enumerable with all duplicate values removed |
method IEnumerable<T> distinct <EQ, T> (IEnumerable<T> list) Source #
Return a new enumerable with all duplicate values removed
type | T | Enumerable item type |
param | list | Enumerable |
returns | A new enumerable with all duplicate values removed |
method IEnumerable<T> distinct <T, K> (IEnumerable<T> list, Func<T, K> keySelector, Option<Func<K, K, bool>> compare = default) Source #
Return a new enumerable with all duplicate values removed
type | T | Enumerable item type |
param | list | Enumerable |
returns | A new enumerable with all duplicate values removed |
method IEnumerable<T> take <T> (IEnumerable<T> list, int count) Source #
Returns a new enumerable with the first 'count' items from the enumerable provided
type | T | Enumerable item type |
param | list | Enumerable |
param | count | Number of items to take |
returns | A new enumerable with the first 'count' items from the enumerable provided |
method IEnumerable<T> takeWhile <T> (IEnumerable<T> list, Func<T, bool> pred) Source #
Iterate the list, yielding items if they match the predicate provided, and stopping as soon as one doesn't
type | T | Enumerable item type |
param | list | Enumerable |
param | count | Number of items to take |
returns | A new enumerable with the first items that match the predicate |
method IEnumerable<T> takeWhile <T> (IEnumerable<T> list, Func<T, int, bool> pred) Source #
Iterate the list, 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 | T | Enumerable item type |
param | list | Enumerable |
param | count | Number of items to take |
returns | A new enumerable with the first items that match the predicate |
method IEnumerable<S> unfold <S> (S state, Func<S, Option<S>> unfolder) Source #
Generate a new list from an intial state value and an 'unfolding' function. The unfold function generates the items in the resulting list until None is returned.
type | S | State type |
param | state | Initial state |
param | unfolder | Unfold function |
returns | Unfolded enumerable |
method IEnumerable<A> unfold <S, A> (S state, Func<S, Option<(A, S)>> unfolder) Source #
Generate a new list from an intial state value and an 'unfolding' function. An aggregate state value is threaded through separately to the yielded value. The unfold function generates the items in the resulting list until None is returned.
type | A | Bound value of resulting enumerable |
type | S | State type |
param | state | Initial state |
param | unfolder | Unfold function |
returns | Unfolded enumerable |
method IEnumerable<A> unfold <S1, S2, A> ((S1, S2) state, Func<S1, S2, Option<(A, S1, S2)>> unfolder) Source #
Generate a new list from an intial state value and an 'unfolding' function. An aggregate state value is threaded through separately to the yielded value. The unfold function generates the items in the resulting list until None is returned.
type | A | Bound value of resulting enumerable |
type | S1 | State type |
type | S2 | State type |
param | state | Initial state |
param | unfolder | Unfold function |
returns | Unfolded enumerable |
method IEnumerable<A> unfold <S1, S2, S3, A> ((S1, S2, S3) state, Func<S1, S2, S3, Option<(A, S1, S2, S3)>> unfolder) Source #
Generate a new list from an intial state value and an 'unfolding' function. An aggregate state value is threaded through separately to the yielded value. The unfold function generates the items in the resulting list until None is returned.
type | A | Bound value of resulting enumerable |
type | S1 | State type |
type | S2 | State type |
type | S3 | State type |
param | state | Initial state |
param | unfolder | Unfold function |
returns | Unfolded enumerable |
method IEnumerable<A> unfold <S1, S2, S3, S4, A> ((S1, S2, S3, S4) state, Func<S1, S2, S3, S4, Option<(A, S1, S2, S3, S4)>> unfolder) Source #
Generate a new list from an intial state value and an 'unfolding' function. An aggregate state value is threaded through separately to the yielded value. The unfold function generates the items in the resulting list until None is returned.
type | A | Bound value of resulting enumerable |
type | S1 | State type |
type | S2 | State type |
type | S3 | State type |
type | S4 | State type |
param | state | Initial state |
param | unfolder | Unfold function |
returns | Unfolded enumerable |
method bool exists <T> (IEnumerable<T> list, Func<T, bool> pred) Source #
Returns true if any item in the enumerable matches the predicate provided
type | T | Enumerable item type |
param | list | Enumerable to test |
param | pred | Predicate |
returns | True if any item in the enumerable matches the predicate provided |
method IEnumerable<IEnumerable<T>> tails <T> (IEnumerable<T> self) Source #
The tails function returns all final segments of the argument, longest first. For example, i.e. tails(['a','b','c']) == [['a','b','c'], ['b','c'], ['c'],[]]
type | T | List item type |
param | self | List |
returns | Enumerable of Enumerables of T |
method (IEnumerable<T> Initial, IEnumerable<T> Remainder) span <T> (IEnumerable<T> self, Func<T, bool> pred) Source #
Span, applied to a predicate 'pred' and a list, returns a tuple where first element is longest prefix (possibly empty) of elements that satisfy 'pred' and second element is the remainder of the list:
type | T | List element type |
param | self | List |
param | pred | Predicate |
returns | Split list |
List.span(List(1,2,3,4,1,2,3,4), x => x 〈 3) == (List(1,2),List(3,4,1,2,3,4))
List.span(List(1,2,3), x => x 〈 9) == (List(1,2,3),List())
List.span(List(1,2,3), x => x 〈 0) == (List(),List(1,2,3))
method Lst<B> map <A, B> (Func<A, B> f, K<Lst, 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 Lst<B> action <A, B> (K<Lst, A> ma, K<Lst, B> mb) Source #
Applicative action: runs the first applicative, ignores the result, and returns the second applicative
method Lst<B> apply <A, B> (K<Lst, Func<A, B>> mf, K<Lst, 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 |