- Stack
- rev <T> (Stck<T> stack)
- isEmpty <T> (Stck<T> stack)
- clear <T> (Stck<T> stack)
- peek <T> (Stck<T> stack)
- peek <T> (Stck<T> stack, Action<T> Some, Action None)
- peek <T, R> (Stck<T> stack, Func<T, R> Some, Func<R> None)
- trypeek <T> (Stck<T> stack)
- pop <T> (Stck<T> stack)
- trypop <T> (Stck<T> stack)
- pop <T> (Stck<T> stack, Action<T> Some, Action None)
- pop <T, R> (Stck<T> stack, Func<Stck<T>, T, R> Some, Func<R> None)
- push <T> (Stck<T> stack, T value)
- map <T, R> (Stck<T> stack, Func<T, R> map)
- map <T, R> (Stck<T> stack, Func<int, T, R> map)
- filter <T> (Stck<T> stack, Func<T, bool> predicate)
- choose <T, U> (Stck<T> stack, Func<T, Option<U>> selector)
- choose <T, U> (Stck<T> stack, Func<int, T, Option<U>> selector)
- collect <T, R> (Stck<T> stack, Func<T, IEnumerable<R>> map)
- append <T> (Stck<T> lhs, IEnumerable<T> rhs)
- fold <S, T> (Stck<T> stack, S state, Func<S, T, S> folder)
- foldBack <S, T> (Stck<T> stack, S state, Func<S, T, S> folder)
- foldWhile <S, T> (Stck<T> stack, S state, Func<S, T, S> folder, Func<T, bool> preditem)
- foldWhile <S, T> (Stck<T> stack, S state, Func<S, T, S> folder, Func<S, bool> predstate)
- foldBackWhile <S, T> (Stck<T> stack, S state, Func<S, T, S> folder, Func<T, bool> preditem)
- foldBackWhile <S, T> (Stck<T> stack, S state, Func<S, T, S> folder, Func<S, bool> predstate)
- reduce <T> (Stck<T> stack, Func<T, T, T> reducer)
- reduceBack <T> (Stck<T> stack, Func<T, T, T> reducer)
- scan <S, T> (Stck<T> stack, S state, Func<S, T, S> folder)
- scanBack <S, T> (Stck<T> stack, S state, Func<S, T, S> folder)
- find <T> (Stck<T> stack, Func<T, bool> pred)
- zip <T, U, V> (Stck<T> stack, IEnumerable<U> other, Func<T, U, V> zipper)
- length <T> (Stck<T> stack)
- iter <T> (Stck<T> stack, Action<T> action)
- iter <T> (Stck<T> stack, Action<int, T> action)
- forall <T> (Stck<T> stack, Func<T, bool> pred)
- distinct <T> (Stck<T> stack)
- distinct <EQ, T> (Stck<T> stack)
- distinct <T, K> (Stck<T> stack, Func<T, K> keySelector, Option<Func<K, K, bool>> compare = default(Option<Func<K, K, bool>>))
- take <T> (Stck<T> stack, int count)
- takeWhile <T> (Stck<T> stack, Func<T, bool> pred)
- takeWhile <T> (Stck<T> stack, Func<T, int, bool> pred)
- exists <T> (Stck<T> stack, Func<T, bool> pred)
- StackExtensions
- Map <T, R> (this Stck<T> stack, Func<T, R> map)
- Map <T, R> (this Stck<T> stack, Func<int, T, R> map)
- Filter <T> (this Stck<T> stack, Func<T, bool> predicate)
- Choose <T, U> (this Stck<T> stack, Func<T, Option<U>> selector)
- Choose <T, U> (this Stck<T> stack, Func<int, T, Option<U>> selector)
- Collect <T, R> (this Stck<T> stack, Func<T, IEnumerable<R>> map)
- Rev <T> (this Stck<T> stack)
- Fold <S, T> (this Stck<T> stack, S state, Func<S, T, S> folder)
- FoldBack <S, T> (this Stck<T> stack, S state, Func<S, T, S> folder)
- FoldWhile <S, T> (this Stck<T> stack, S state, Func<S, T, S> folder, Func<T, bool> preditem)
- FoldWhile <S, T> (this Stck<T> stack, S state, Func<S, T, S> folder, Func<S, bool> predstate)
- FoldBackWhile <S, T> (this Stck<T> stack, S state, Func<S, T, S> folder, Func<T, bool> preditem)
- FoldBackWhile <S, T> (this Stck<T> stack, S state, Func<S, T, S> folder, Func<S, bool> predstate)
- ReduceBack <T> (Stck<T> stack, Func<T, T, T> reducer)
- Reduce <T> (this Stck<T> stack, Func<T, T, T> reducer)
- Scan <S, T> (this Stck<T> stack, S state, Func<S, T, S> folder)
- ScanBack <S, T> (this Stck<T> stack, S state, Func<S, T, S> folder)
- Find <T> (this Stck<T> stack, Func<T, bool> pred)
- Length <T> (this Stck<T> stack)
- Iter <T> (this Stck<T> stack, Action<T> action)
- Iter <T> (this Stck<T> stack, Action<int, T> action)
- ForAll <T> (this Stck<T> stack, Func<T, bool> pred)
- Distinct <T> (this Stck<T> stack)
- Distinct <EQ,T> (this Stck<T> stack)
- Distinct <T, K> (this Stck<T> stack, Func<T, K> keySelector, Option<Func<K, K, bool>> compare = default(Option<Func<K, K, bool>>))
- Take <T> (this Stck<T> stack, int count)
- TakeWhile <T> (this Stck<T> stack, Func<T, bool> pred)
- TakeWhile <T> (this Stck<T> stack, Func<T, int, bool> pred)
- Exists <T> (this Stck<T> stack, Func<T, bool> pred)
- Stck <A>
- Empty = new Stck<A>(StckInternal<A>.Empty)
- Stck (IEnumerable<A> initial)
- Case
- Reverse ()
- IsEmpty
- Count
- Length
- Clear ()
- GetEnumerator ()
- ToSeq ()
- ToString ()
- ToFullString (string separator = ", ")
- ToFullArrayString (string separator = ", ")
- AsEnumerable ()
- Do (Action<A> f)
- Peek ()
- Peek (Action<A> Some, Action None)
- Peek <R> (Func<A, R> Some, Func<R> None)
- TryPeek ()
- Pop ()
- TryPop ()
- Pop (Action<A> Some, Action None)
- Pop <R> (Func<Stck<A>, A, R> Some, Func<R> None)
- Push (A value)
- + (Stck<A> lhs, Stck<A> rhs)
- Append (Stck<A> rhs)
- - (Stck<A> lhs, Stck<A> rhs)
- Subtract (Stck<A> rhs)
- == (Stck<A> lhs, Stck<A> rhs)
- != (Stck<A> lhs, Stck<A> rhs)
- GetHashCode ()
- Equals (object obj)
- Equals (Stck<A> other)
Functional module for working with the Stck T type
method Stck<T> rev <T> (Stck<T> stack) Source #
Reverses the order of the items in the stack
returns |
method Stck<T> clear <T> (Stck<T> stack) Source #
Clear the stack (returns Empty)
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 InvalidOperationException if the stack is empty
returns | Top item value |
method Stck<T> peek <T> (Stck<T> stack, Action<T> Some, Action None) Source #
Peek and match
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
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
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 InvalidOperationException if the stack is empty
returns | Stack with the top item popped |
method (Stck<T>, Option<T>) trypop <T> (Stck<T> stack) Source #
Safe pop
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
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
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
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).
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).
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)
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)).
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.
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.
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.
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)
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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
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
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.
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)
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
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 #
Return an enumerable with all duplicate values removed
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
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
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
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.
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 |
class StackExtensions Source #
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).
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).
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)
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)).
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.
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.
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
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)
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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
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.
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
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
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 #
Return an enumerable with all duplicate values removed
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
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
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
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.
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 |
Immutable stack
type | A | Stack element type |
field Stck<A> Empty = new Stck<A>(StckInternal<A>.Empty) 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 => ...,
_ => ...
}
method IEnumerator<A> GetEnumerator () Source #
Get enumerator
returns | IEnumerator of T |
method Seq<A> ToSeq () Source #
Returns the stack as a Sq. The first item in the sequence will be the item at the top of the stack.
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 IEnumerable<A> AsEnumerable () Source #
Returns the stack as an IEnumerable. The first item in the enumerable will be the item at the top of the stack.
returns | IEnumerable of T |
method Stck<A> Do (Action<A> f) Source #
Impure iteration of the bound value in the structure
returns | Returns the original unmodified structure |
Return the item on the top of the stack without affecting the stack itself NOTE: Will throw an InvalidOperationException if the stack is empty
returns | Top item value |
method Stck<A> Peek (Action<A> Some, Action None) Source #
Peek and match
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
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
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 InvalidOperationException if the stack is empty
returns | Stack with the top item popped |
method (Stck<A> Stack, Option<A> Value) TryPop () Source #
Safe pop
returns | Tuple of popped stack and optional top-of-stack value |
method Stck<A> Pop (Action<A> Some, Action None) Source #
Pop and match
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
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
param | value | Item to push |
returns | New stack with the pushed item on top |
method Stck<A> Append (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.
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.
param | rhs | Stack to append |
returns | Appended stacks |
method int GetHashCode () Source #
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.