LanguageExt.Core

LanguageExt.Core Immutable Collections Seq

Contents

struct Seq <A> Source #

Cons sequence 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

Indexers

this [ A ] Source #

Indexer

Properties

property Seq<A> Empty Source #

Empty sequence

property object? Case Source #

Reference version for use in pattern-matching

property Lens<Seq<A>, A> head Source #

Head lens

property Lens<Seq<A>, Option<A>> headOrNone Source #

Head or none lens

property Lens<Seq<A>, Seq<A>> tail Source #

Tail lens

property Lens<Seq<A>, A> last Source #

Last lens

property Lens<Seq<A>, Option<A>> lastOrNone Source #

Last or none lens

property Option<A> Head Source #

Head item in the sequence.

If IsEmpty is true then Head is undefined and therefore returns None

property Seq<A> Tail Source #

Tail of the sequence

property Seq<A> Init Source #

Get all items except the last one

property Option<A> Last Source #

Last item in sequence

property bool IsEmpty Source #

Returns true if the sequence is empty

For lazy streams this will have to peek at the first item. So, the first item will be consumed.

property int Count Source #

Returns the number of items in the sequence

Parameters

returns

Number of items in the sequence

property int Length Source #

Alias of Count

Parameters

returns

Number of items in the sequence

property Seq<Seq<A>> Inits Source #

Returns all initial segments of the sequence, shortest first

Including the empty sequence

Parameters

returns

Initial segments of the sequence

Examples

 Seq("a", "b", "c").Inits

 > Seq(Seq(), Seq("a"), Seq("a", "b"), Seq("a", "b", "c"))

property Seq<Seq<A>> NonEmptyInits Source #

Returns all initial segments of the sequence, shortest first.

Not including the empty sequence

Parameters

returns

Initial segments of the sequence

Examples

 Seq("a", "b", "c").Inits

 > Seq(Seq("a"), Seq("a", "b"), Seq("a", "b", "c"))

property Seq<Seq<A>> Tails Source #

Returns all final segments of the argument, longest first.

Including the empty sequence

Parameters

returns

Initial segments of the sequence

Examples

 Seq("a", "b", "c").Tails

 > Seq(Seq("a", "b", "c"), Seq("a", "b"), Seq("a"), Seq())

property Seq<Seq<A>> NonEmptyTails Source #

Returns all final segments of the argument, longest first.

Not including the empty sequence

Parameters

returns

Initial segments of the sequence

Examples

 Seq("a", "b", "c").Tails

 > Seq(Seq("a", "b", "c"), Seq("a", "b"), Seq("a"))

property Seq<A> AdditiveIdentity Source #

Constructors

constructor Seq (IEnumerable<A> ma) Source #

Constructor from lazy sequence

constructor Seq (ReadOnlySpan<A> ma) Source #

Constructor from lazy sequence

Methods

method void Deconstruct (out A head, out Seq<A> tail) Source #

method Lens<Seq<A>, Seq<B>> map <B> (Lens<A, B> lens) Source #

Lens map

method Seq<A> Add (A value) Source #

Add an item to the end of the sequence

Forces evaluation of the entire lazy sequence so the item can be appended

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

Add a range of items to the end of the sequence

method Seq<A> Concat (in Lst<A> items) Source #

Add a range of items to the end of the sequence

Forces evaluation of the entire lazy sequence so the items can be appended.

method Seq<A> Concat (in ReadOnlySpan<A> items) Source #

Add a range of items to the end of the sequence

Forces evaluation of the entire lazy sequence so the items can be appended.

method Seq<A> Concat (in Set<A> items) Source #

Add a range of items to the end of the sequence

Forces evaluation of the entire lazy sequence so the items can be appended.

method Seq<A> Concat (in HashSet<A> items) Source #

Add a range of items to the end of the sequence

Forces evaluation of the entire lazy sequence so the items can be appended.

method Seq<A> Concat (in Arr<A> items) Source #

Add a range of items to the end of the sequence

Forces evaluation of the entire lazy sequence so the items can be appended.

method Seq<A> Concat (in Stck<A> items) Source #

Add a range of items to the end of the sequence

Forces evaluation of the entire lazy sequence so the items can be appended.

method Seq<A> Concat (IReadOnlyCollection<A> items) Source #

Add a range of items to the end of the sequence

Forces evaluation of the entire lazy sequence so the items can be appended.

method Seq<A> Concat (in Seq<A> rhs) Source #

Add a range of items to the end of the sequence

Forces evaluation of the entire lazy sequence so the items can be appended.

method IEnumerable<A> AsEnumerable () Source #

Stream as an enumerable

method StreamT<M, A> AsStream <M> () Source #

where M : Monad<M>

Stream as an enumerable

method Iterable<A> AsIterable () Source #

Stream as an enumerable

method B Match <B> ( Func<B> Empty, Func<A, Seq<A>, B> Tail) Source #

Match empty sequence, or multi-item sequence

Parameters

type B

Return value type

param Empty

Match for an empty list

param Tail

Match for a non-empty

returns

Result of match function invoked

method B Match <B> ( Func<B> Empty, Func<A, B> Head, Func<A, Seq<A>, B> Tail) Source #

Match empty sequence, or one item sequence, or multi-item sequence

Parameters

type B

Return value type

param Empty

Match for an empty list

param Tail

Match for a non-empty

returns

Result of match function invoked

method B Match <B> ( Func<B> Empty, Func<Seq<A>, B> Seq) Source #

Match empty sequence, or multi-item sequence

Parameters

type B

Return value type

param Empty

Match for an empty list

param Sequence

Match for a non-empty

returns

Result of match function invoked

method B Match <B> ( Func<B> Empty, Func<A, B> Head, Func<Seq<A>, B> Tail) Source #

Match empty sequence, or one item sequence, or multi-item sequence

Parameters

type B

Return value type

param Empty

Match for an empty list

param Tail

Match for a non-empty

returns

Result of match function invoked

method Seq<A> Do (Action<A> f) Source #

Impure iteration of the bound values in the structure

Parameters

returns

Returns the original unmodified structure

method K<F, Seq<B>> Traverse <F, B> (Func<A, K<F, B>> f) Source #

where F : Applicative<F>

Map each element of a structure to an action, evaluate these actions from left to right, and collect the results.

Parameters

type F

Applicative functor trait

type B

Bound value (output)

param f
param ta

Traversable structure

method K<M, Seq<B>> TraverseM <M, B> (Func<A, K<M, B>> f) Source #

where M : Monad<M>

Map each element of a structure to an action, evaluate these actions from left to right, and collect the results.

Parameters

type M

Monad trait

type B

Bound value (output)

param f
param ta

Traversable structure

method Seq<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 Seq<B> Map <B> (Func<A, int, B> f) Source #

Map the sequence using the function provided

Exposes an index for each map

Parameters

returns

Mapped sequence

method Seq<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 Seq<B> Bind <B> (Func<A, Seq<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 Seq<B> Bind <B> (Func<A, K<Seq, 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 Seq<C> SelectMany <B, C> (Func<A, Seq<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 Seq<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 Seq<A> Where (Func<A, bool> f) Source #

Filter the items in the sequence

Parameters

param f

Predicate to apply to the items

returns

Filtered sequence

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

Returns true if the supplied predicate returns true for any item in the sequence. False otherwise.

Parameters

param f

Predicate to apply

returns

True if the supplied predicate returns true for any item in the sequence. False otherwise.

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

Returns true if the supplied predicate returns true for all items in the sequence. False otherwise. If there is an empty sequence then true is returned.

Parameters

param f

Predicate to apply

returns

True if the supplied predicate returns true for all items in the sequence. False otherwise. If there is an empty sequence then true is returned.

method bool Any () Source #

Returns true if the sequence has items in it

Parameters

returns

True if the sequence has items in it

method Seq<A> Intersperse (A value) Source #

Inject a value in between each item in the sequence

Parameters

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 GetHashCode () Source #

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

Parameters

returns

method int CompareTo (object? obj) Source #

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 Seq<A> Combine (Seq<A> y) Source #

method bool Equals (object? obj) Source #

Equality test

method bool Equals (Seq<A> rhs) Source #

Equality test

method bool Equals <EqA> (Seq<A> rhs) Source #

where EqA : Eq<A>

Equality test

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

Skip count items

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

Take count items

method Seq<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 Seq<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 (Seq<A> First, Seq<A> Second) Partition (Func<A, bool> predicate) Source #

Partition a list into two based on a predicate

Parameters

param predicate

True if the item goes in the first list, false for the second list

returns

Pair of lists

method int CompareTo (Seq<A> rhs) Source #

Compare to another sequence

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

where OrdA : Ord<A>

Compare to another sequence

method Seq<A> Strict () Source #

Force all items lazy to stream

method IEnumerator<A> GetEnumerator () Source #

method Seq<B> Cast <B> () Source #

Operators

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

Append operator

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

Append operator

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

Append operator

operator | (Seq<A> x, K<Seq, A> y) Source #

Choice operator

operator | (K<Seq, A> x, Seq<A> y) Source #

Choice operator

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

Ordering operator

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

Ordering operator

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

Ordering operator

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

Ordering operator

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

Equality operator

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

Non-equality operator

class SeqExtensions Source #

Methods

method Seq<A> As <A> (this K<Seq, A> xs) Source #

method Seq<A> Flatten <A> (this Seq<Seq<A>> ma) Source #

Monadic join

method Seq<B> Choose <A, B> (this Seq<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)).

Parameters

type A

sequence item type

param list

sequence

param selector

Selector function

returns

Mapped and filtered sequence

method Seq<B> Choose <A, B> (this Seq<A> list, Func<int, 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)). An index value is passed through to the selector function also.

Parameters

type A

sequence item type

param list

sequence

param selector

Selector function

returns

Mapped and filtered sequence

method Seq<T> Rev <T> (this Seq<T> list) Source #

Reverses the sequence (Reverse in LINQ)

Parameters

type T

sequence item type

param list

sequence to reverse

returns

Reversed sequence

method Seq<T> Append <T> (this Seq<T> lhs, Seq<T> rhs) Source #

Concatenate two sequences (Concat in LINQ)

Parameters

type T

sequence item type

param lhs

First sequence

param rhs

Second sequence

returns

Concatenated sequence

method Seq<T> Append <T> (this Seq<T> x, Seq<Seq<T>> xs) Source #

Concatenate a sequence and a sequence of sequences

Parameters

type T

List item type

param lhs

First list

param rhs

Second list

returns

Concatenated list

method Seq<S> Scan <S, T> (this Seq<T> list, S state, Func<S, T, 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.

Parameters

type S

State type

type T

sequence item type

param list

sequence to fold

param state

Initial state

param folder

Folding function

returns

Aggregate state

method Seq<S> ScanBack <S, T> (this Seq<T> list, S state, Func<S, T, 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.

Parameters

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 Seq<V> Zip <T, U, V> (this Seq<T> list, Seq<U> other, Func<T, U, V> 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 Seq<(T First, U Second)> Zip <T, U> (this Seq<T> list, Seq<U> 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 Seq<T> Distinct <T> (this Seq<T> list) Source #

Return a new sequence with all duplicate values removed

Parameters

type T

sequence item type

param list

sequence

returns

A new sequence with all duplicate values removed

method Seq<T> Distinct <EQ, T> (this Seq<T> list) Source #

where EQ : Eq<T>

Return a new sequence with all duplicate values removed

Parameters

type T

sequence item type

param list

sequence

returns

A new sequence with all duplicate values removed

method Seq<T> Distinct <T, K> (this Seq<T> list, Func<T, K> keySelector, Option<Func<K, K, bool>> compare = default) Source #

Return a new sequence with all duplicate values removed

Parameters

type T

sequence item type

param list

sequence

returns

A new sequence with all duplicate values removed

method Seq<Seq<A>> Tails <A> (this Seq<A> self) Source #

The tails function returns all final segments of the argument, longest first. For example:

tails(['a','b','c']) == [['a','b','c'], ['b','c'], ['c'],[]]

Parameters

type A

Seq item type

param self

Seq

returns

Seq of Seq of A

method (Seq<T>, Seq<T>) Span <T> (this Seq<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:

Parameters

type T

List element type

param self

List

param pred

Predicate

returns

Split list

Examples

Seq.span(List(1,2,3,4,1,2,3,4), x => x 〈 3) == (List(1,2),List(3,4,1,2,3,4))

Seq.span(List(1,2,3), x => x 〈 9) == (List(1,2,3),List())

Seq.span(List(1,2,3), x => x 〈 0) == (List(),List(1,2,3))

method IQueryable<A> AsQueryable <A> (this Seq<A> source) Source #

Convert to a queryable

Parameters

returns

class SeqExtensions Source #

Methods

method Seq<B> Map <A, B> (this Func<A, B> f, K<Seq, 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.

Parameters

param ma

Functor to map

param f

Mapping function

returns

Mapped functor

method Seq<B> Map <A, B> (this Func<A, B> f, Seq<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.

Parameters

param ma

Functor to map

param f

Mapping function

returns

Mapped functor

method Seq<B> Action <A, B> (this Seq<A> ma, K<Seq, B> mb) Source #

Applicative action: runs the first applicative, ignores the result, and returns the second applicative

method Seq<B> Action <A, B> (this K<Seq, A> ma, K<Seq, B> mb) Source #

Applicative action: runs the first applicative, ignores the result, and returns the second applicative

method Seq<B> Apply <A, B> (this Seq<Func<A, B>> mf, K<Seq, 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.

Parameters

param ma

Value(s) applicative functor

param mf

Mapping function(s)

returns

Mapped applicative functor

method Seq<B> Apply <A, B> (this K<Seq, Func<A, B>> mf, K<Seq, 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.

Parameters

param ma

Value(s) applicative functor

param mf

Mapping function(s)

returns

Mapped applicative functor

class Seq 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 Seq<A> flatten <A> (Seq<Seq<A>> ma) Source #

Monadic join

method Seq<A> empty <A> () Source #

Create an empty sequence

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

Create an empty sequence

method Seq<A> create <A> () Source #

Create a new empty sequence

Parameters

returns

sequence

method Seq<A> create <A> (params A[] items) Source #

Create a sequence from a initial set of items

Parameters

param items

Items

returns

sequence

method Seq<A> createRange <A> (ReadOnlySpan<A> items) Source #

Create a sequence from an initial set of items

Parameters

param items

Items

returns

sequence

method Seq<A> createRange <A> (IEnumerable<A> items) Source #

Create a sequence from an initial set of items

Parameters

param items

Items

returns

sequence

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

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

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

Generates a sequence that contains one repeated value.

method Option<A> head <A> (Seq<A> list) Source #

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

Parameters

param list

sequence

returns

Head item

method Option<A> last <A> (Seq<A> list) Source #

Get the last item of the sequence

Parameters

param list

sequence

returns

Last item

method Seq<A> init <A> (Seq<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

Parameters

param list

List

returns

The initial items (all but the last)

method Seq<A> tail <A> (Seq<A> list) Source #

Get the tail of the sequence (skips the head item)

Parameters

param list

sequence

returns

Tail sequence

method Seq<B> map <A, B> (Seq<A> list, Func<A, B> map) Source #

Projects the values in the sequence using a map function into a new sequence (Select in LINQ).

Parameters

type A

sequence item type

type B

Return sequence item type

param list

sequence to map

param map

Map function

returns

Mapped sequence

method Seq<B> map <A, B> (Seq<A> list, Func<int, A, B> map) Source #

Projects the values in the sequence into a new sequence 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).

Parameters

type A

sequence item type

type B

Return sequence item type

param list

sequence to map

param map

Map function

returns

Mapped sequence

method Seq<A> filter <A> (Seq<A> list, Func<A, bool> predicate) Source #

Removes items from the sequence that do not match the given predicate (Where in LINQ)

Parameters

type A

sequence item type

param list

sequence to filter

param predicate

Predicate function

returns

Filtered sequence

method Seq<B> choose <A, B> (Seq<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)).

Parameters

type A

sequence item type

param list

sequence

param selector

Selector function

returns

Mapped and filtered sequence

method Seq<B> choose <A, B> (Seq<A> list, Func<int, 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)). An index value is passed through to the selector function also.

Parameters

type A

sequence item type

param list

sequence

param selector

Selector function

returns

Mapped and filtered sequence

method Seq<T> rev <T> (Seq<T> list) Source #

Reverses the sequence (Reverse in LINQ)

Parameters

type T

sequence item type

param list

sequence to reverse

returns

Reversed sequence

method Seq<T> append <T> (Seq<T> lhs, Seq<T> rhs) Source #

Concatenate two sequences (Concat in LINQ)

Parameters

type T

sequence item type

param lhs

First sequence

param rhs

Second sequence

returns

Concatenated sequence

method Seq<T> append <T> (Seq<T> x, Seq<Seq<T>> xs) Source #

Concatenate a sequence and a sequence of sequences

Parameters

type T

List item type

param lhs

First list

param rhs

Second list

returns

Concatenated list

method Seq<T> append <T> (params Seq<T>[] lists) Source #

Concatenate N sequences

Parameters

type T

sequence type

param lists

sequences to concatenate

returns

A single sequence with all of the items concatenated

method Seq<S> scan <S, T> (Seq<T> list, S state, Func<S, T, 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.

Parameters

type S

State type

type T

sequence item type

param list

sequence to fold

param state

Initial state

param folder

Folding function

returns

Aggregate state

method Seq<S> scanBack <S, T> (Seq<T> list, S state, Func<S, T, 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.

Parameters

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 Seq<V> zip <T, U, V> (Seq<T> list, Seq<U> other, Func<T, U, V> 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 Seq<(T First, U Second)> zip <T, U> (Seq<T> list, Seq<U> 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 bool forall <T> (Seq<T> list, Func<T, bool> pred) Source #

Returns true if all items in the sequence match a predicate (Any in LINQ)

Parameters

type T

sequence item type

param list

sequence to test

param pred

Predicate

returns

True if all items in the sequence match the predicate

method Seq<T> distinct <T> (Seq<T> list) Source #

Return a new sequence with all duplicate values removed

Parameters

type T

sequence item type

param list

sequence

returns

A new sequence with all duplicate values removed

method Seq<T> distinct <EQ, T> (Seq<T> list) Source #

where EQ : Eq<T>

Return a new sequence with all duplicate values removed

Parameters

type T

sequence item type

param list

sequence

returns

A new sequence with all duplicate values removed

method Seq<T> distinct <T, K> (Seq<T> list, Func<T, K> keySelector, Option<Func<K, K, bool>> compare = default) Source #

Return a new sequence with all duplicate values removed

Parameters

type T

sequence item type

param list

sequence

returns

A new sequence with all duplicate values removed

method Seq<T> take <T> (Seq<T> list, int count) Source #

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

Parameters

type T

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 Seq<T> takeWhile <T> (Seq<T> list, Func<T, bool> pred) Source #

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

Parameters

type T

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 Seq<T> takeWhile <T> (Seq<T> list, Func<T, 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 T

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 Seq<Seq<A>> tails <A> (Seq<A> self) Source #

The tails function returns all final segments of the argument, longest first. For example:

tails(['a','b','c']) == [['a','b','c'], ['b','c'], ['c'],[]]

Parameters

type A

Seq item type

param self

Seq

returns

Seq of Seq of A

method Seq<Seq<A>> tailsr <A> (Seq<A> self) Source #

The tailsr function returns all final segments of the argument, longest first. For example:

tails(['a','b','c']) == [['a','b','c'], ['b','c'], ['c'],[]]

Differs from tails in implementation only. The tailsr uses recursive processing whereas tails uses a while loop aggregation followed by a reverse. For small sequences tailsr is probably more efficient.

Parameters

type A

Seq item type

param self

Seq

returns

Seq of Seq of A

method (Seq<T>, Seq<T>) span <T> (Seq<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:

Parameters

type T

List element type

param self

List

param pred

Predicate

returns

Split list

Examples

Seq.span(Seq(1,2,3,4,1,2,3,4), x => x 〈 3) == (Seq(1,2), Seq(3,4,1,2,3,4))

Seq.span(Seq(1,2,3), x => x 〈 9) == (Seq(1,2,3), Seq())

Seq.span(Seq(1,2,3), x => x 〈 0) == (Seq(), Seq(1,2,3))

class Seq Source #

class Prelude Source #

Methods

method Seq<B> map <A, B> (Func<A, B> f, K<Seq, 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.

Parameters

param ma

Functor to map

param f

Mapping function

returns

Mapped functor

method Seq<B> action <A, B> (K<Seq, A> ma, K<Seq, B> mb) Source #

Applicative action: runs the first applicative, ignores the result, and returns the second applicative

method Seq<B> apply <A, B> (K<Seq, Func<A, B>> mf, K<Seq, 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.

Parameters

param ma

Value(s) applicative functor

param mf

Mapping function(s)

returns

Mapped applicative functor

struct SeqEmpty Source #

A unit type that represents Seq.Empty. This type can be implicitly converted to Seq〈A〉.

Fields

field SeqEmpty Default = new() Source #

struct Enumerator Source #

Properties

property ref A Current Source #

Methods

method bool MoveNext () Source #

class SeqLoan <A> Source #

Represents a sequence on loan from an ArrayPool

This supports rapid reading of data for use in streaming situations. As soon as any transformations are made the backing data is baked into a Seq of A. This involves cloning the original array (because obviously the rented array will be returned to the pool eventually).

You can manually call Dispose() to release the Array, however it also supports a finaliser to return the backing array back to its pool of origin.

NOTE: If you call Dispose() whilst using this structure on another thread, behaviour is undefined.

Parameters

type A

Bound value

Indexers

this [ A ] Source #

Indexer

Properties

property A Head Source #

Head item in the sequence. NOTE: If IsEmpty is true then Head is undefined. Call HeadOrNone() if for maximum safety.

property Seq<A> Tail Source #

Tail of the sequence

property Seq<A> Init Source #

property bool IsEmpty Source #

Returns true if the sequence is empty

For lazy streams this will have to peek at the first item. So, the first item will be consumed.

property A Last Source #

Last item in sequence. Throws if no items in sequence

property int Count Source #

Returns the number of items in the sequence

Parameters

returns

Number of items in the sequence

Methods

method SeqLoan<A> Rent (ArrayPool<A> pool, int size) Source #

Create a newly rented array

method SeqLoan<A> Rent (int size) Source #

Create a newly rented array

method Seq<A> ToSeq () Source #

Clone to a Seq

method ReadOnlySpan<A> ToReadOnlySpan () Source #

method Span<A> ToSpan () Source #

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

Fold the sequence from the first item to the last

Parameters

type S

State type

param state

Initial state

param f

Fold function

returns

Aggregated state

method S FoldBack <S> (S state, Func<S, A, S> f) Source #

Fold the sequence from the last item to the first. For sequences that are not lazy and are less than 5000 items long, FoldBackRec is called instead, because it is faster.

Parameters

type S

State type

param state

Initial state

param f

Fold function

returns

Aggregated state

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

Skip count items

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

Take count items

method Enumerator GetEnumerator () Source #

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

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

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

method Seq<A> Append (Seq<A> right) Source #

method Seq<A> Append (SeqLoan<A> right) Source #

method int GetHashCode () Source #

method void Dispose () Source #