Seq<A> Class

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.

DECLARATION
public abstract class Seq<A> : ISeq<A>
NAMESPACE
LanguageExt

Fields

Empty
DECLARATION
public static readonly Seq<A> Empty

Properties

Count
SUMMARY

Returns the number of items in the sequence

DECLARATION
public int Count { get; }
RETURNS
int
Number of items in the sequence
Head
SUMMARY

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

DECLARATION
public virtual A Head { get; }
RETURNS
A
IsEmpty
SUMMARY

True if this cons node is the Empty node

DECLARATION
public bool IsEmpty { get; }
RETURNS
bool
Tail
SUMMARY

Tail of the sequence

DECLARATION
public abstract Seq<A> Tail { get; }
RETURNS
Seq<A>

Methods

Any()
SUMMARY

Returns true if the sequence has items in it

DECLARATION
public bool Any()
RETURNS
bool
True if the sequence has items in it
AsEnumerable()
SUMMARY

Stream as an enumerable

DECLARATION
public virtual IEnumerable<A> AsEnumerable()
RETURNS
IEnumerable<A>
Bind<B>(Func<A, Seq<B>>)
SUMMARY

Monadic bind (flatmap) of the sequence

PARAMETERS
f
Func<A, Seq<B>>
Bind function
DECLARATION
public Seq<B> Bind<B>(Func<A, Seq<B>> f)
RETURNS
Seq<B>
Flatmapped sequence
CompareTo(ISeq<A>)
SUMMARY

Compare to another sequence

PARAMETERS
other
ISeq<A>
DECLARATION
public int CompareTo(ISeq<A> other)
RETURNS
int
Equals(object)
SUMMARY

Equality test

PARAMETERS
obj
object
DECLARATION
public override bool Equals(object obj)
RETURNS
bool
Equals(ISeq<A>)
SUMMARY

Equality test

PARAMETERS
rhs
ISeq<A>
DECLARATION
public virtual bool Equals(ISeq<A> rhs)
RETURNS
bool
Exists(Func<A, bool>)
SUMMARY

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

PARAMETERS
f
Func<A, bool>
Predicate to apply
DECLARATION
public bool Exists(Func<A, bool> f)
RETURNS
bool
True if the supplied predicate returns true for any item in the sequence. False otherwise.
Filter(Func<A, bool>)
SUMMARY

Filter the items in the sequence

PARAMETERS
f
Func<A, bool>
Predicate to apply to the items
DECLARATION
public Seq<A> Filter(Func<A, bool> f)
RETURNS
Seq<A>
Filtered sequence
Fold<S>(S, Func<S, A, S>)
SUMMARY

Fold the sequence from the first item to the last

PARAMETERS
state
S
Initial state
f
Func<S, A, S>
Fold function
DECLARATION
public S Fold<S>(S state, Func<S, A, S> f)
RETURNS
S
Aggregated state
FoldBack<S>(S, Func<S, A, S>)
SUMMARY

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
state
S
Initial state
f
Func<S, A, S>
Fold function
DECLARATION
public S FoldBack<S>(S state, Func<S, A, S> f)
RETURNS
S
Aggregated state
FoldBackRec<S>(S, Func<S, A, S>)
SUMMARY

Fold the sequence (recursively) from the last item to the first. This is faster than FoldBack, but be wary of calling this with sequences that are large, you can blow the stack.

PARAMETERS
state
S
Initial state
f
Func<S, A, S>
Fold function
DECLARATION
public S FoldBackRec<S>(S state, Func<S, A, S> f)
RETURNS
S
Aggregated state
ForAll(Func<A, bool>)
SUMMARY

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
f
Func<A, bool>
Predicate to apply
DECLARATION
public bool ForAll(Func<A, bool> f)
RETURNS
bool
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.
GetEnumerator()
SUMMARY

Get an enumerator for the sequence

DECLARATION
public virtual IEnumerator<A> GetEnumerator()
RETURNS
IEnumerator<A>
An IEnumerator of As
GetHashCode()
SUMMARY

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

DECLARATION
public override int GetHashCode()
RETURNS
int
HeadOrNone()
SUMMARY

Head of the sequence if this node isn't the empty node

DECLARATION
public Option<A> HeadOrNone()
RETURNS
Option<A>
Map<B>(Func<A, B>)
SUMMARY

Map the sequence using the function provided

PARAMETERS
f
Func<A, B>
Mapping function
DECLARATION
public Seq<B> Map<B>(Func<A, B> f)
RETURNS
Seq<B>
Mapped sequence
Match<B>(Func<B>, Func<A, Seq<A>, B>)
SUMMARY

Match empty sequence, or multi-item sequence

PARAMETERS
Empty
Func<B>
Match for an empty list
Tail
Func<A, Seq<A>, B>
Match for a non-empty
DECLARATION
public virtual B Match<B>(Func<B> Empty, Func<A, Seq<A>, B> Tail)
RETURNS
B
Result of match function invoked
Match<B>(Func<B>, Func<A, B>, Func<A, Seq<A>, B>)
SUMMARY

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

PARAMETERS
Empty
Func<B>
Match for an empty list
Head
Func<A, B>
Tail
Func<A, Seq<A>, B>
Match for a non-empty
DECLARATION
public virtual B Match<B>(Func<B> Empty, Func<A, B> Head, Func<A, Seq<A>, B> Tail)
RETURNS
B
Result of match function invoked
Match<B>(Func<B>, Func<Seq<A>, B>)
SUMMARY

Match empty sequence, or multi-item sequence

PARAMETERS
Empty
Func<B>
Match for an empty list
Seq
Func<Seq<A>, B>
DECLARATION
public virtual B Match<B>(Func<B> Empty, Func<Seq<A>, B> Seq)
RETURNS
B
Result of match function invoked
Match<B>(Func<B>, Func<A, B>, Func<Seq<A>, B>)
SUMMARY

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

PARAMETERS
Empty
Func<B>
Match for an empty list
Head
Func<A, B>
Tail
Func<Seq<A>, B>
Match for a non-empty
DECLARATION
public virtual B Match<B>(Func<B> Empty, Func<A, B> Head, Func<Seq<A>, B> Tail)
RETURNS
B
Result of match function invoked
Select<B>(Func<A, B>)
SUMMARY

Map the sequence using the function provided

PARAMETERS
f
Func<A, B>
Mapping function
DECLARATION
public Seq<B> Select<B>(Func<A, B> f)
RETURNS
Seq<B>
Mapped sequence
SelectMany<B, C>(Func<A, Seq<B>>, Func<A, B, C>)
SUMMARY

Monadic bind (flatmap) of the sequence

PARAMETERS
bind
Func<A, Seq<B>>
Bind function
project
Func<A, B, C>
DECLARATION
public Seq<C> SelectMany<B, C>(Func<A, Seq<B>> bind, Func<A, B, C> project)
RETURNS
Seq<C>
Flatmapped sequence
Skip(int)
SUMMARY

Skip count items

PARAMETERS
count
int
DECLARATION
public virtual Seq<A> Skip(int count)
RETURNS
Seq<A>
Take(int)
SUMMARY

Take count items

PARAMETERS
count
int
DECLARATION
public virtual Seq<A> Take(int count)
RETURNS
Seq<A>
TakeWhile(Func<A, bool>)
SUMMARY

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

PARAMETERS
pred
Func<A, bool>
DECLARATION
public virtual Seq<A> TakeWhile(Func<A, bool> pred)
RETURNS
Seq<A>
A new sequence with the first items that match the predicate
TakeWhile(Func<A, int, bool>)
SUMMARY

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
pred
Func<A, int, bool>
DECLARATION
public virtual Seq<A> TakeWhile(Func<A, int, bool> pred)
RETURNS
Seq<A>
A new sequence with the first items that match the predicate
Where(Func<A, bool>)
SUMMARY

Filter the items in the sequence

PARAMETERS
f
Func<A, bool>
Predicate to apply to the items
DECLARATION
public Seq<A> Where(Func<A, bool> f)
RETURNS
Seq<A>
Filtered sequence