LanguageExt.Core

LanguageExt.Core Immutable Collections Stack

Contents

class StackExtensions Source #

Methods

method Stck<R> Map <T, R> (this Stck<T> stack, Func<T, R> map) Source #

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

Parameters

type T

Stack item type

type R

Return enumerable item type

param stack

Stack to map

param map

Map function

returns

Mapped enumerable

method Stck<R> Map <T, R> (this Stck<T> stack, Func<int, T, R> map) Source #

Projects the values in the stack into a new stack 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 T

Stack item type

type R

Return enumerable item type

param stack

Stack to map

param map

Map function

returns

Mapped enumerable

method Stck<T> Filter <T> (this Stck<T> stack, Func<T, bool> predicate) Source #

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

Parameters

type T

Stack item type

param stack

Stack to filter

param predicate

Predicate function

returns

Filtered stack

method Stck<U> Choose <T, U> (this Stck<T> stack, Func<T, Option<U>> selector) Source #

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

Parameters

type T

Stack item type

param stack

Stack

param selector

Selector function

returns

Mapped and filtered enumerable

method Stck<U> Choose <T, U> (this Stck<T> stack, Func<int, T, Option<U>> selector) Source #

Applies the given function 'selector' to each element of the stack. Returns an enumerable 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 T

Stack item type

param stack

Stack

param selector

Selector function

returns

Mapped and filtered enumerable

method Stck<R> Collect <T, R> (this Stck<T> stack, Func<T, IEnumerable<R>> map) Source #

For each element of the stack, applies the given function. Concatenates all the results and returns the combined list.

Parameters

type T

Stack item type

type R

Return enumerable item type

param stack

Stack to map

param map

Map function

returns

Mapped enumerable

method Stck<T> Rev <T> (this Stck<T> stack) Source #

Reverses the order of the items in the stack

Parameters

returns

method S Fold <S, T> (this Stck<T> stack, 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 stack. 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)

Parameters

type S

State type

type T

Stack item type

param stack

Stack to fold

param state

Initial state

param folder

Fold function

returns

Aggregate value

method S FoldBack <S, T> (this Stck<T> stack, 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 stack. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result.

Parameters

type S

State type

type T

Stack item type

param stack

Stack to fold

param state

Initial state

param folder

Fold function

returns

Aggregate value

method S FoldWhile <S, T> (this Stck<T> stack, 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 stack. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result.

Parameters

type S

State type

type T

Stack item type

param stack

Stack to fold

param state

Initial state

param folder

Fold function

param preditem

Predicate function

returns

Aggregate value

method S FoldWhile <S, T> (this Stck<T> stack, 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 stack. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result.

Parameters

type S

State type

type T

Stack item type

param stack

Stack to fold

param state

Initial state

param folder

Fold function

param predstate

Predicate function

returns

Aggregate value

method S FoldBackWhile <S, T> (this Stck<T> stack, 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 stack. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result.

Parameters

type S

State type

type T

Stack item type

param stack

Stack to fold

param state

Initial state

param folder

Fold function

param preditem

Predicate function

returns

Aggregate value

method S FoldBackWhile <S, T> (this Stck<T> stack, 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 stack. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result.

Parameters

type S

State type

type T

Stack item type

param stack

Stack to fold

param state

Initial state

param folder

Fold function

param predstate

Predicate function

returns

Aggregate value

method T ReduceBack <T> (Stck<T> stack, 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 stack. Then, it passes this result into the function along with the third element and so on. Finally, it returns the final result.

Parameters

type T

Stack item type

param stack

Stack

param reducer

Reduce function

returns

Aggregate value

method T Reduce <T> (this Stck<T> stack, 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 stack. Then, it passes this result into the function along with the third element and so on. Finally, it returns the final result.

Parameters

type T

Stack item type

param stack

Stack to fold

param reducer

Reduce function

returns

Aggregate value

method Stck<S> Scan <S, T> (this Stck<T> stack, 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 stack. 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

Stack item type

param stack

Stack

param state

Initial state

param folder

Folding function

returns

Aggregate state

method Stck<S> ScanBack <S, T> (this Stck<T> stack, 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 stack. 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

Stack item type

param stack

Stack

param state

Initial state

param folder

Folding function

returns

Aggregate state

method Option<T> Find <T> (this Stck<T> stack, Func<T, bool> pred) Source #

Returns Some(x) for the first item in the stack that matches the predicate provided, None otherwise.

Parameters

type T

Stack item type

param stack

Stack

param pred

Predicate

returns

Some(x) for the first item in the stack that matches the predicate provided, None otherwise.

method int Length <T> (this Stck<T> stack) Source #

Returns the number of items in the stack

Parameters

type T

Stack item type

param stack

Stack

returns

The number of items in the enumerable

method Unit Iter <T> (this Stck<T> stack, Action<T> action) Source #

Invokes an action for each item in the stack in order

Parameters

type T

Stack item type

param stack

Stack to iterate

param action

Action to invoke with each item

returns

Unit

method Unit Iter <T> (this Stck<T> stack, Action<int, T> action) Source #

Invokes an action for each item in the stack in order and supplies a running index value.

Parameters

type T

Stack item type

param stack

Stack to iterate

param action

Action to invoke with each item

returns

Unit

method bool ForAll <T> (this Stck<T> stack, Func<T, bool> pred) Source #

Return an enumerable with all duplicate values removed

Parameters

type T

Stack item type

param stack

Stack

returns

An enumerable with all duplicate values removed

method Stck<T> Distinct <T> (this Stck<T> stack) Source #

Return an enumerable with all duplicate values removed

Parameters

type T

Stack item type

param stack

Stack

returns

An enumerable with all duplicate values removed

method Stck<T> Distinct <EQ,T> (this Stck<T> stack) Source #

where EQ : Eq<T>

Return an enumerable with all duplicate values removed

Parameters

type T

Stack item type

param stack

Stack

returns

An enumerable with all duplicate values removed

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

Return an enumerable with all duplicate values removed

Parameters

type T

Stack item type

param stack

Stack

returns

An enumerable with all duplicate values removed

method Stck<T> Take <T> (this Stck<T> stack, int count) Source #

Returns a new enumerable with the first 'count' items from the stack

Parameters

type T

Stack item type

param stack

Stack

param count

Number of items to take

returns

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

method Stck<T> TakeWhile <T> (this Stck<T> stack, Func<T, bool> pred) Source #

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

Parameters

type T

Stack item type

param stack

Stack

param count

Number of items to take

returns

A new enumerable with the first items that match the predicate

method Stck<T> TakeWhile <T> (this Stck<T> stack, Func<T, int, bool> pred) Source #

Iterate the stack, 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

Stack item type

param stack

Stack

param count

Number of items to take

returns

A new enumerable with the first items that match the predicate

method bool Exists <T> (this Stck<T> stack, Func<T, bool> pred) Source #

Returns true if any item in the stack matches the predicate provided

Parameters

type T

Stack item type

param stack

Stack

param pred

Predicate

returns

True if any item in the stack matches the predicate provided

class Stack Source #

Functional module for working with the Stck T type

Methods

method Stck<A> singleton <A> (A item) Source #

Create a new stack from a single element

Parameters

type A

Type of the items

param item

Item to populate the singleton stack

returns

Constructed stack collection

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

Create a new stack from an existing span

Parameters

type A

Type of the items

param items

Items to populate the stack

returns

Constructed stack collection

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

Create a new stack from an existing span

Parameters

type A

Type of the items

param items

Items to populate the stack

returns

Constructed stack collection

method Stck<T> rev <T> (Stck<T> stack) Source #

Reverses the order of the items in the stack

Parameters

returns

method bool isEmpty <T> (Stck<T> stack) Source #

True if the stack is empty

method Stck<T> clear <T> (Stck<T> stack) Source #

Clear the stack (returns Empty)

Parameters

returns

Stck.Empty of T

method T peek <T> (Stck<T> stack) Source #

Return the item on the top of the stack without affecting the stack itself NOTE: Will throw an ExpectedException if the stack is empty

Parameters

returns

Top item value

method Stck<T> peek <T> (Stck<T> stack, Action<T> Some, Action None) Source #

Peek and match

Parameters

param Some

Handler if there is a value on the top of the stack

param None

Handler if the stack is empty

returns

Untouched stack

method R peek <T, R> (Stck<T> stack, Func<T, R> Some, Func<R> None) Source #

Peek and match

Parameters

type R

Return type

param Some

Handler if there is a value on the top of the stack

param None

Handler if the stack is empty

returns

Return value from Some or None

method Option<T> trypeek <T> (Stck<T> stack) Source #

Safely return the item on the top of the stack without affecting the stack itself

Parameters

returns

Returns the top item value, or None

method Stck<T> pop <T> (Stck<T> stack) Source #

Pop an item off the top of the stack NOTE: Will throw an ExpectedException if the stack is empty

Parameters

returns

Stack with the top item popped

method (Stck<T>, Option<T>) trypop <T> (Stck<T> stack) Source #

Safe pop

Parameters

returns

Tuple of popped stack and optional top-of-stack value

method Stck<T> pop <T> (Stck<T> stack, Action<T> Some, Action None) Source #

Pop and match

Parameters

param Some

Handler if there is a value on the top of the stack

param None

Handler if the stack is empty

returns

Popped stack

method R pop <T, R> (Stck<T> stack, Func<Stck<T>, T, R> Some, Func<R> None) Source #

Pop and match

Parameters

type R

Return type

param Some

Handler if there is a value on the top of the stack

param None

Handler if the stack is empty

returns

Return value from Some or None

method Stck<T> push <T> (Stck<T> stack, T value) Source #

Push an item onto the stack

Parameters

param value

Item to push

returns

New stack with the pushed item on top

method Stck<R> map <T, R> (Stck<T> stack, Func<T, R> map) Source #

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

Parameters

type T

Stack item type

type R

Return enumerable item type

param stack

Stack to map

param map

Map function

returns

Mapped enumerable

method Stck<R> map <T, R> (Stck<T> stack, Func<int, T, R> map) Source #

Projects the values in the stack 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).

Parameters

type T

Stack item type

type R

Return enumerable item type

param stack

Stack to map

param map

Map function

returns

Mapped enumerable

method Stck<T> filter <T> (Stck<T> stack, Func<T, bool> predicate) Source #

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

Parameters

type T

Stack item type

param stack

Stack to filter

param predicate

Predicate function

returns

Filtered stack

method Stck<U> choose <T, U> (Stck<T> stack, Func<T, Option<U>> selector) Source #

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

Parameters

type T

Stack item type

param stack

Stack

param selector

Selector function

returns

Mapped and filtered enumerable

method Stck<U> choose <T, U> (Stck<T> stack, Func<int, T, Option<U>> selector) Source #

Applies the given function 'selector' to each element of the stack. Returns an enumerable 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 T

Stack item type

param stack

Stack

param selector

Selector function

returns

Mapped and filtered enumerable

method Stck<R> collect <T, R> (Stck<T> stack, Func<T, IEnumerable<R>> map) Source #

For each element of the stack, applies the given function. Concatenates all the results and returns the combined list.

Parameters

type T

Stack item type

type R

Return enumerable item type

param stack

Stack to map

param map

Map function

returns

Mapped enumerable

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

Append another stack to the top of this stack The rhs will be reversed and pushed onto 'this' stack. That will maintain the order of the items in the resulting stack. So the top of 'rhs' will be the top of the newly created stack. 'this' stack will be under the 'rhs' stack.

Parameters

param rhs

Stack to append

returns

Appended stacks

method S fold <S, T> (Stck<T> stack, 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 stack. 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)

Parameters

type S

State type

type T

Stack item type

param stack

Stack to fold

param state

Initial state

param folder

Fold function

returns

Aggregate value

method S foldBack <S, T> (Stck<T> stack, 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 stack. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result.

Parameters

type S

State type

type T

Stack item type

param stack

Stack to fold

param state

Initial state

param folder

Fold function

returns

Aggregate value

method S foldWhile <S, T> (Stck<T> stack, 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 stack. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result.

Parameters

type S

State type

type T

Stack item type

param stack

Stack to fold

param state

Initial state

param folder

Fold function

param preditem

Predicate function

returns

Aggregate value

method S foldWhile <S, T> (Stck<T> stack, 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 stack. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result.

Parameters

type S

State type

type T

Stack item type

param stack

Stack to fold

param state

Initial state

param folder

Fold function

param predstate

Predicate function

returns

Aggregate value

method S foldBackWhile <S, T> (Stck<T> stack, 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 stack. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result.

Parameters

type S

State type

type T

Stack item type

param stack

Stack to fold

param state

Initial state

param folder

Fold function

param preditem

Predicate function

returns

Aggregate value

method S foldBackWhile <S, T> (Stck<T> stack, 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 stack. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result.

Parameters

type S

State type

type T

Stack item type

param stack

Stack to fold

param state

Initial state

param folder

Fold function

param predstate

Predicate function

returns

Aggregate value

method T reduce <T> (Stck<T> stack, 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 stack. Then, it passes this result into the function along with the third element and so on. Finally, it returns the final result.

Parameters

type T

Stack item type

param stack

Stack to fold

param reducer

Reduce function

returns

Aggregate value

method T reduceBack <T> (Stck<T> stack, 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 stack. Then, it passes this result into the function along with the third element and so on. Finally, it returns the final result.

Parameters

type T

Stack item type

param stack

Stack

param reducer

Reduce function

returns

Aggregate value

method Stck<S> scan <S, T> (Stck<T> stack, 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 stack. 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

Stack item type

param stack

Stack

param state

Initial state

param folder

Folding function

returns

Aggregate state

method Stck<S> scanBack <S, T> (Stck<T> stack, 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 stack. 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

Stack item type

param stack

Stack

param state

Initial state

param folder

Folding function

returns

Aggregate state

method Option<T> find <T> (Stck<T> stack, Func<T, bool> pred) Source #

Returns Some(x) for the first item in the stack that matches the predicate provided, None otherwise.

Parameters

type T

Stack item type

param stack

Stack

param pred

Predicate

returns

Some(x) for the first item in the stack that matches the predicate provided, None otherwise.

method Stck<V> zip <T, U, V> (Stck<T> stack, IEnumerable<U> other, Func<T, U, V> zipper) Source #

Joins a stack and and enumerable together either into a single enumerable using the join function provided

Parameters

param stack

First stack to join

param other

Second list to join

param zipper

Join function

returns

Joined enumerable

method int length <T> (Stck<T> stack) Source #

Returns the number of items in the stack

Parameters

type T

Stack item type

param stack

Stack

returns

The number of items in the enumerable

method Unit iter <T> (Stck<T> stack, Action<T> action) Source #

Invokes an action for each item in the stack in order

Parameters

type T

Stack item type

param stack

Stack to iterate

param action

Action to invoke with each item

returns

Unit

method Unit iter <T> (Stck<T> stack, Action<int, T> action) Source #

Invokes an action for each item in the stack in order and supplies a running index value.

Parameters

type T

Stack item type

param stack

Stack to iterate

param action

Action to invoke with each item

returns

Unit

method bool forall <T> (Stck<T> stack, Func<T, bool> pred) Source #

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

Parameters

type T

Stack item type

param stack

Stack to test

param pred

Predicate

returns

True if all items in the stack match the predicate

method Stck<T> distinct <T> (Stck<T> stack) Source #

Return an enumerable with all duplicate values removed

Parameters

type T

Stack item type

param stack

Stack

returns

An enumerable with all duplicate values removed

method Stck<T> distinct <EQ, T> (Stck<T> stack) Source #

where EQ : Eq<T>

Return an enumerable with all duplicate values removed

Parameters

type T

Stack item type

param stack

Stack

returns

An enumerable with all duplicate values removed

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

Return an enumerable with all duplicate values removed

Parameters

type T

Stack item type

param stack

Stack

returns

An enumerable with all duplicate values removed

method Stck<T> take <T> (Stck<T> stack, int count) Source #

Returns a new enumerable with the first 'count' items from the stack

Parameters

type T

Stack item type

param stack

Stack

param count

Number of items to take

returns

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

method Stck<T> takeWhile <T> (Stck<T> stack, Func<T, bool> pred) Source #

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

Parameters

type T

Stack item type

param stack

Stack

param count

Number of items to take

returns

A new enumerable with the first items that match the predicate

method Stck<T> takeWhile <T> (Stck<T> stack, Func<T, int, bool> pred) Source #

Iterate the stack, 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

Stack item type

param stack

Stack

param count

Number of items to take

returns

A new enumerable with the first items that match the predicate

method bool exists <T> (Stck<T> stack, Func<T, bool> pred) Source #

Returns true if any item in the stack matches the predicate provided

Parameters

type T

Stack item type

param stack

Stack

param pred

Predicate

returns

True if any item in the stack matches the predicate provided

struct Stck <A> Source #

Immutable stack

Parameters

type A

Stack element type

Properties

property Stck<A> Empty Source #

property object? Case Source #

Reference version for use in pattern-matching

Empty collection     = null
Singleton collection = A
More                 = (A, Seq<A>)   -- head and tail

var res = stack.Case switch
{

   (var x, var xs) => ...,
   A value         => ...,
   _               => ...
}

property bool IsEmpty Source #

Is the stack empty

property int Count Source #

Number of items in the stack

property int Length Source #

Alias of Count

Constructors

constructor Stck (IEnumerable<A> initial) Source #

Ctor that takes an initial state as an IEnumerable T

constructor Stck (ReadOnlySpan<A> initial) Source #

Ctor that takes an initial state as an IEnumerable T

Methods

method Stck<A> Reverse () Source #

Reverses the order of the items in the stack

Parameters

returns

method Stck<A> Clear () Source #

Clear the stack (returns Empty)

Parameters

returns

Stck.Empty of T

method IEnumerator<A> GetEnumerator () Source #

Get enumerator

Parameters

returns

IEnumerator of T

method Seq<A> ToSeq () Source #

Returns the stack as a Seq. The first item in the sequence will be the item at the top of the stack.

Parameters

returns

IEnumerable of T

method string ToString () Source #

Format the collection as [a, b, c, ...] The elipsis 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 #

Returns the stack as an IEnumerable. The first item in the enumerable will be the item at the top of the stack.

Parameters

returns

IEnumerable of T

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

Impure iteration of the bound value in the structure

Parameters

returns

Returns the original unmodified structure

method A Peek () Source #

Return the item on the top of the stack without affecting the stack itself NOTE: Will throw an ExpectedException if the stack is empty

Parameters

returns

Top item value

method Stck<A> Peek (Action<A> Some, Action None) Source #

Peek and match

Parameters

param Some

Handler if there is a value on the top of the stack

param None

Handler if the stack is empty

returns

Untouched stack (this)

method R Peek <R> (Func<A, R> Some, Func<R> None) Source #

Peek and match

Parameters

type R

Return type

param Some

Handler if there is a value on the top of the stack

param None

Handler if the stack is empty

returns

Return value from Some or None

method Option<A> TryPeek () Source #

Safely return the item on the top of the stack without affecting the stack itself

Parameters

returns

Returns the top item value, or None

method Stck<A> Pop () Source #

Pop an item off the top of the stack NOTE: Will throw an ExpectedException if the stack is empty

Parameters

returns

Stack with the top item popped

method (Stck<A> Stack, Option<A> Value) TryPop () Source #

Safe pop

Parameters

returns

Tuple of popped stack and optional top-of-stack value

method Stck<A> Pop (Action<A> Some, Action None) Source #

Pop and match

Parameters

param Some

Handler if there is a value on the top of the stack

param None

Handler if the stack is empty

returns

Popped stack

method R Pop <R> (Func<Stck<A>, A, R> Some, Func<R> None) Source #

Pop and match

Parameters

type R

Return type

param Some

Handler if there is a value on the top of the stack

param None

Handler if the stack is empty

returns

Return value from Some or None

method Stck<A> Push (A value) Source #

Push an item onto the stack

Parameters

param value

Item to push

returns

New stack with the pushed item on top

method Stck<A> Combine (Stck<A> rhs) Source #

Append another stack to the top of this stack The rhs will be reversed and pushed onto 'this' stack. That will maintain the order of the items in the resulting stack. So the top of 'rhs' will be the top of the newly created stack. 'this' stack will be under the 'rhs' stack.

Parameters

param rhs

Stack to append

returns

Appended stacks

method Stck<A> Subtract (Stck<A> rhs) Source #

Append another stack to the top of this stack The rhs will be reversed and pushed onto 'this' stack. That will maintain the order of the items in the resulting stack. So the top of 'rhs' will be the top of the newly created stack. 'this' stack will be under the 'rhs' stack.

Parameters

param rhs

Stack to append

returns

Appended stacks

method int GetHashCode () Source #

method bool Equals (object? obj) Source #

method bool Equals (Stck<A> other) Source #

Operators

operator + (Stck<A> lhs, Stck<A> rhs) Source #

Append another stack to the top of this stack The rhs will be reversed and pushed onto 'this' stack. That will maintain the order of the items in the resulting stack. So the top of 'rhs' will be the top of the newly created stack. 'this' stack will be under the 'rhs' stack.

operator - (Stck<A> lhs, Stck<A> rhs) Source #

Subtract one stack from another: lhs except rhs

operator == (Stck<A> lhs, Stck<A> rhs) Source #

operator != (Stck<A> lhs, Stck<A> rhs) Source #