gostack

package module
v1.0.51 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2023 License: MIT Imports: 7 Imported by: 2

README

v1.0.5 — Beta Release — 01/26/2022 — Patch A

Banner

"The purpose of abstraction is not to be vague, but to create a new semantic level in which one can be absolutely precise." - Edsger W. Dijkstra

Glossary

Introduction

Documentation

Tutorials

General


Join our official Discord community! It is devoted to helping users resolve gostack bugs and related issues, announcing exciting updates, making improvements based on user suggestions, and streamlining communication between developers and gostackers. Although a fully functional release of gostack has been published, this is a growing project with many updates to come.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CLONE

type CLONE int
const (
	CLONE_False CLONE = iota
	CLONE_True
)

type COMPARE

type COMPARE int
const (
	COMPARE_False COMPARE = iota
	COMPARE_True
)

type Card

type Card struct {
	Idx int
	Key any
	Val any
}

func MakeCard

func MakeCard(arguments ...any) *Card

* Creates a card with given properties

MakeCard(input1 any [nil], input2 any [nil], idx int [-1]) (*Card)

@ensures | IF `input1` OR `input2` are nil: | MakeCard := func(`val`, `key`, `idx`) | ELSE: | MakeCard := func(`key`, `val`, `idx`) @examples | MakeCard("Hello") => Card{Val: "Hello"} | MakeCard(nil, "Hello") => Card{Key: "Hello"} | MakeCard(1, 2) => Card{Key: 1, Val: 2}

func (*Card) Clone

func (card *Card) Clone() *Card

* Returns a clone of `card`

card.Clone() (newCard card)

func (*Card) Equals

func (thisCard *Card) Equals(otherCard *Card, arguments ...any) bool

* Returns whether one card equals another

 card.Equals(
    otherCard *Card,
    compareIdxs COMPARE [COMPARE_False],
    compareKeys COMPARE [COMPARE_True],
    compareVals COMPARE [COMPARE_True],
	compareCardPtrs COMPARE [COMPARE_False],
    pointerKeys DEREFERENCE [DEREFERENCE_None],
    pointerVals DEREFERENCE [DEREFERENCE_None]
 ) (cardEqualsOtherCard bool)

 @examples
 | card1 := MakeCard("Hey")
 | card2 := MakeCard("Hey")
 | myStr := "Hey"
 | card1.Equals(card2, nil, nil, nil, COMPARE_False) // True
 | card1.Equals(card2, nil, nil, nil, COMPARE_True) // False
 | card1.Equals(MakeCard(&myStr), nil, nil, nil, nil, nil, DEREFERENCE_This) // True

func (*Card) Print

func (card *Card) Print(arguments ...any) *Card

* Prints information surrounding `card` to the terminal and returns `card`

card.Print(name string [""], indent int [0]) (card)

@ensures
| prints "-" `indent` * 4 times before each line to indicate depth in a stackMatrix

func (*Card) SwitchKeyVal

func (card *Card) SwitchKeyVal() *Card

* Switches the Key and the Val of `card`

card.SwitchKeyVal() (card)

type DEEPSEARCH

type DEEPSEARCH int
const (
	DEEPSEARCH_False DEEPSEARCH = iota
	DEEPSEARCH_True
)

type DEREFERENCE

type DEREFERENCE int
const (
	DEREFERENCE_None DEREFERENCE = iota
	DEREFERENCE_Both
	DEREFERENCE_Found
	DEREFERENCE_This
)

type FIND

type FIND int
const (
	FIND_First FIND = iota
	FIND_Last
	FIND_Idx
	FIND_Key
	FIND_Val
	FIND_KeyVal
	FIND_Card
	FIND_Coords
	FIND_Size
	FIND_Height
	FIND_Slice
	FIND_All
	FIND_Lambda
)

type ORDER

type ORDER int
const (
	ORDER_Before ORDER = iota
	ORDER_After
)

type OVERRIDE

type OVERRIDE int
const (
	OVERRIDE_False OVERRIDE = iota
	OVERRIDE_True
)

type PASS

type PASS int
const (
	PASS_Cards PASS = iota
	PASS_Substacks
	PASS_Both
)

type REPEAT

type REPEAT int
const (
	REPEAT_False REPEAT = iota
	REPEAT_True
)

type REPLACE

type REPLACE int
const (
	REPLACE_Key REPLACE = iota
	REPLACE_Val
	REPLACE_Card
	REPLACE_Lambda
)

type RETURN

type RETURN int
const (
	RETURN_Idxs RETURN = iota
	RETURN_Keys
	RETURN_Vals
	RETURN_Cards
	RETURN_Adrs
	RETURN_Stacks
)

type Stack

type Stack struct {
	Cards  []*Card
	Size   int
	Height int
}

func CSVToStackMatrix

func CSVToStackMatrix(inPath string) (out *Stack)

* Takes a CSV at a given file path and returns it as a StackMatrix

CSVToStackMatrix(inPath string) (newStackMatrix *Stack)

@notes

| IF fails to convert the CSV: | returns an empty Stack

@requires
| `inPath` points to valid CSV file

func MakeStack

func MakeStack(arguments ...any) *Stack

* Creates a stack initialized with starting cards

MakeStack(input1 []any|map[any]any|*Stack [nil], input2 []any|*Stack [nil], repeats int [1]) (newStack *Stack)

Where all mentions of array are interchangeable with Stack:
@notes
| Makes `repeats` repeats of `input1`/`input2`
@requires
| `input1` is a map and `input2` is nil
|     OR `input1` is an array and `input2` is nil
|     OR `input1` is an array and `input2` is an array
|     OR `input1` is nil and `input2` is an array
|
| IF `input1` AND `input2` are both passed as arguments
|      |`input1`| == |`input2`|
@ensures
|     IF `input1` is passed
|       IF `input1` is a map
|         unpack the map into new cards with corresponding keys and vals
|       ELSEIF `input1` is an array and `input2` is not passed/nil
|  	   IF `input1` is an array of cards:
|           unpack cards in `input1` into `stack`
|  	   ELSE:
|           unpack values from `input1` into new cards
|       ELSEIF `input1` is an array and `input2` is an array
|         unpack keys from `input1` and values from `input2` into new cards
|       ELSEIF `input1` is nil and `input2` is an array
|         unpack keys from `input2` into new cards
|  		make `repeats` cards with nil value and nil key
|  		ELSEIF `input1` is nil and `input2` is nil and `repeats` is passed
|     ELSE
|       the stack is empty
@examples
| MakeStack([]int {1, 2, 3}) => Stack{Vals: {1, 2, 3}}
| MakeStack(nil, []int {1, 2, 3}) => Stack{Keys: {1, 2, 3}}
| MakeStack([]string {"a", "b", "c"}, []int {1, 2, 3}) => Stack{Keys: {"a", "b", "c"}, Vals: {1, 2, 3}}
| MakeStack(map[string]int {"a":1, "b":2, "c":3}) => Stack{Keys: {"a", "b", "c"}, Vals: {1, 2, 3}} // but not necessarily in this order
| MakeStack(nil, nil, 5) => Stack{nil, nil, nil, nil, nil}

func MakeStackMatrix

func MakeStackMatrix(arguments ...any) *Stack

* Creates a stack matrix initialized with starting cards

MakeStackMatrix(input1 []any (deep/shallow)|map[any]any (deep/shallow)|*Stack [nil], input2 []any (deep/shallow)|*Stack [nil], matrixShape []int|*Stack [[]int {1}]) (newStackMatrix *Stack)

Where all mentions of array are interchangeable with Stack:
@requires
| `input1` is a map and `input2` is nil
|     OR `input1` is an array and `input2` is nil
|     OR `input1` is an array and `input2` is an array
|     OR `input1` is nil and `input2` is an array
|
| IF `input1` AND `input2` are both passed as arguments:
|      |`input1`| == |`input2`|
|
| `matrixShape` must be an int array representing the shape of a regularly-shaped matrix where:
| * the first int defines `newStackMatrix.Size`
| * the last int defines the size of each final stack
| * the product of `matrixShape` is equal to the amount of elements in your input(s)
@ensures
| Using the same logic as MakeStack() in deciding which of the first two inputs is a key/val:
|
|  IF no `matrixShape` is passed:
|    treating `input1`/`input2` as matrices ([]any {[]any {...}, []any {...}, ..., []any {...}})/a map of matrices (map[any]map[any]...map[any]any)/a StackMatrix:
|    IF `input1` is passed:
|      IF `input1` is a map:
|        unpack the map into matrix of shape `inputx` with corresponding keys and vals
|      ELSEIF `input1` is an array and `input2` is nil:
|        unpack values from `input1` into matrix of shape `inputx`
|      ELSEIF `input1` is an array and `input2` is an array:
|        unpack keys from `input1` and values from `input2` into matrix of shape `inputx`
|      ELSEIF `input1` is nil and `input2` is an array:
|        unpack keys from `input2` into matrix of shape `inputx`
|    ELSEIF `input1` and `input2` are nil:
|      the stack is empty
|    ELSEIF `matrixShape` is passed:
|      treating `input1`/`input2` as 1D structures ([]any, map[any]any, Stack):
|      IF `input1` is a map:
|        unpack the map into matrix of shape `matrixShape` with corresponding keys and vals
|      ELSEIF `input1` is an array and `input2` is nil:
|        IF `input1` is an array of cards:
|          unpack cards from `input1` into `stack`
|        ELSE:
|          unpack values from `input1` into new cards
|      ELSEIF `input1` is an array and `input2` is an array:
|        unpack keys from `input1` and values from `input2` into matrix of shape `matrixShape`
|      ELSEIF `input1` is nil and `input2` is an array:
|        unpack keys from `input2` into matrix of shape `matrixShape`
|      ELSEIF `input1` is nil AND `input2` is nil:
|        create a StackMatrix of shape `matrixShape` whose heightest card keys/vals are nil
@examples
| MakeStackMatrix([]int {1, 2, 3, 4}, nil, []int {2, 2}) => Stack{Stack{1, 2}, Stack{3, 4}}
| MakeStackMatrix([]int {1, 2, 3, 4, 5, 6}, nil, []int {2, 3}) => Stack{Stack{1, 2, 3}, Stack{4, 5, 6}}
| MakeStackMatrix([]int {1, 2, 3, 4, 5, 6}, nil, []int {3, 2}) => Stack{Stack{1, 2}, Stack{3, 4}, Stack{5, 6}}
| MakeStackMatrix([]any {[]any {1, 2}, []any {3, 4}}} =>  Stack{Stack{1, 2}, Stack{3, 4}}

func MakeSubstack

func MakeSubstack(arguments ...any) *Stack

* An identical implementation to `MakeStack()`

MakeSubstack(input1 []any|map[any]any|*Stack [nil], input2 any|*Stack [nil], repeats int [1], overrideInsert OVERRIDE [OVERRIDE_False]) (newSubstack *Stack)

@examples
| MakeStack([]*Stack {MakeSubstack([]int {1, 2}), MakeSubstack([]int {3, 4})}) => Stack{Stack{1, 2}, Stack{3, 4}}

func (*Stack) Add

func (stack *Stack) Add(insert any, arguments ...any) *Stack

* Adds `insert` to `stack` before/after first found card and returns `stack`, or nil if invalid find

stack.Add(
   insert any|[]any|*Card|*Stack,
   orderType ORDER [ORDER_After],
   findType FIND [FIND_Last],
   findData any|[]any|*Stack|func(
     card *Card,
     parentStack *Stack,
     isSubstack bool,
     coords *Stack,
     retStack *Stack,
     retCard *Card,
     retVarPtr any,
     otherInfo []any {
           cardPtr,
           parentStackPtr,
           retStackPtr,
           retCardPtr
     },
     workingMem ...any
   ) [nil],
   deepSearchType DEEPSEARCH [DEEPSEARCH_False],
   depth int|[]int|*Stack [-1],
   passType PASS [PASS_Both],
   dereferenceType DEREFERENCE [DEREFERENCE_None],
   overrideInsert OVERRIDE [OVERRIDE_False],
   overrideFindData OVERRIDE [OVERRIDE_False],
   workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}]
) (stack)

@ensures
| IF `overrideInsert` == OVERRIDE_True:
|   insert `insert` itself, rather than the elements within `insert` (assuming it is a stack or array)
| IF `overrideFindData` == OVERRIDE_True:
|   compare whether each element is equal to `findData` itself, rather than each element inside of `findData` (assuming it is a stack or array)
| IF a version for func input data is passed that has fewer parameters than the full function:
|   the function will abstract away unincluded parameters

func (*Stack) AddMany

func (stack *Stack) AddMany(insert any, arguments ...any) *Stack

* Adds `insert` to `stack` before/after each found card and returns `stack`, or nil if invalid find

stack.AddMany(
   insert any|[]any|*Card|*Stack,
   orderType ORDER [ORDER_After],
   findType FIND [FIND_Last],
   findData any|[]any|*Stack|func(
     card *Card,
     parentStack *Stack,
     isSubstack bool,
     coords *Stack,
     retStack *Stack,
     retCard *Card,
     retVarPtr any,
     otherInfo []any {
           cardPtr,
           parentStackPtr,
           retStackPtr,
           retCardPtr
     },
     workingMem ...any
   ) [nil],
   deepSearchType DEEPSEARCH [DEEPSEARCH_False],
   depth int|[]int|*Stack [-1],
   passType PASS [PASS_Both],
   dereferenceType DEREFERENCE [DEREFERENCE_None],
   overrideInsert OVERRIDE [OVERRIDE_False],
   overrideFindData OVERRIDE [OVERRIDE_False],
   workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}]
) (stack)

@ensures
| IF `overrideInsert` == OVERRIDE_True:
|   insert `insert` itself, rather than the elements within `insert` (assuming it is a stack or array)
| IF `overrideFindData` == OVERRIDE_True:
|   compare whether each element is equal to `findData` itself, rather than each element inside of `findData` (assuming it is a stack or array)
| IF a version for func input data is passed that has fewer parameters than the full function:
|   the function will abstract away unincluded parameters

func (*Stack) Clone

func (stack *Stack) Clone(arguments ...any) *Stack

* Returns a clone of `stack`

stack.Clone(deepSearchType DEEPSEARCH [DEEPSEARCH_True], depth int [-1], cloneCardKeys CLONE [CLONE_True], cloneCardVals CLONE [CLONE_True], cloneSubstackKeys CLONE [CLONE_True], cloneSubstackVals CLONE [CLONE_True]) (newStack stack)

@ensures
| If `cloneSubstackVals` == CLONE_False, then each card holding a substack as its Val will have its Val updated to nil

func (*Stack) Coordinates

func (stack *Stack) Coordinates(arguments ...any) *Stack

* Retrieves a stack containing the coordinates of the first found card, or empty stack if doesn't exist

stack.Coordinates(
   findType FIND [FIND_Last],
   findData any|[]any|*Stack|func(
     card *Card,
     parentStack *Stack,
     isSubstack bool,
     coords *Stack,
     retStack *Stack,
     retCard *Card,
     retVarPtr any,
     otherInfo []any {
           cardPtr,
           parentStackPtr,
           retStackPtr,
           retCardPtr
     },
     workingMem ...any
   ) [nil],
   deepSearchType DEEPSEARCH [DEEPSEARCH_True],
   depth int|[]int|*Stack [-1],
   passType PASS [PASS_Cards],
   dereferenceType DEREFERENCE [DEREFERENCE_None],
   overrideFindData OVERRIDE [OVERRIDE_False],
   workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}]
) (foundCardCoords *Stack)

@ensures
| IF `overrideFindData` == OVERRIDE_True:
|   compare whether each element is equal to `findData` itself, rather than each element inside of `findData` (assuming it is a stack or array)
| IF a version for func input data is passed that has fewer parameters than the full function:
|   the function will abstract away unincluded parameters

func (*Stack) CoordinatesMany

func (stack *Stack) CoordinatesMany(arguments ...any) *Stack

* Retrieves a stack containing a set of stacks containing the coordinates of each found card

stack.Coordinates(
   findType FIND [FIND_All],
   findData any|[]any|*Stack|func(
     card *Card,
     parentStack *Stack,
     isSubstack bool,
     coords *Stack,
     retStack *Stack,
     retCard *Card,
     retVarPtr any,
     otherInfo []any {
           cardPtr,
           parentStackPtr,
           retStackPtr,
           retCardPtr
     },
     workingMem ...any
   ) [nil],
   deepSearchType DEEPSEARCH [DEEPSEARCH_True],
   depth int|[]int|*Stack [-1],
   passType PASS [PASS_Cards],
   dereferenceType DEREFERENCE [DEREFERENCE_None],
   overrideFindData OVERRIDE [OVERRIDE_False],
   workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}]
) (foundCardsCoords *Stack)

@ensures
| IF `overrideFindData` == OVERRIDE_True:
|   compare whether each element is equal to `findData` itself, rather than each element inside of `findData` (assuming it is a stack or array)
| IF a version for func input data is passed that has fewer parameters than the full function:
|   the function will abstract away unincluded parameters

func (*Stack) DimensionalityReduce added in v1.0.5

func (stack *Stack) DimensionalityReduce(arguments ...any) *Stack

* Updates a stack to represent a selection within that stack matrix

stack.DimensionalityReduce(idx ...int|[]int|*Stack [[]int {0, 1, ..., stack.Size - 1}]) (stack)

@notes
| This can be used to reduce an ND array structure to a 1D vector structure
| This can be used to select a subset of a matrix
| This can be used to select a card at given coordinates
@requires
| `idx` refers to valid index positions from the stack
@examples
| MakeStack([]*Stack {MakeSubstack([]int {1, 2}), MakeSubstack([]int {3, 4})}).DimensionalityReduce() => Stack {1, 2, 3, 4}
| MakeStack([]*Stack {MakeSubstack([]int {1, 2}), MakeSubstack([]int {3, 4})}).DimensionalityReduce([]int {0, 1}) => Stack {1, 2, 3, 4}
| MakeStack([]*Stack {MakeSubstack([]int {1, 2}), MakeSubstack([]int {3, 4})}).DimensionalityReduce(0) => Stack {1, 2}
| MakeStack([]*Stack {MakeSubstack([]int {1, 2}), MakeSubstack([]int {3, 4})}).DimensionalityReduce(1) => Stack {3, 4}

func (*Stack) Duplicate

func (stack *Stack) Duplicate(arguments ...any) *Stack

* Appends the cards in `stack` to itself `n` - 1 times

stack.Duplicate(n int [2]) (stack)

@examples
| MakeStack([]int {1}).Duplicate(0) // Stack{}
| MakeStack([]int {1}).Duplicate(1) // Stack{1}
| MakeStack([]int {1}).Duplicate(2) // Stack{1, 1}
| MakeStack([]int {1, 2}).Duplicate(3) // Stack{1, 2, 1, 2, 1, 2}

func (*Stack) Empty

func (stack *Stack) Empty() *Stack

* Removes all cards from `stack`

stack.Empty() (stack)

func (*Stack) Equals

func (stack *Stack) Equals(otherStack *Stack, arguments ...any) (test bool)

* Returns whether one stack equals another

stack.Equals(
   otherStack *Stack,
   deepSearchType *DEEPSEARCH [DEEPSEARCH_True],
   depth int|[]int|*Stack [-1],
   compareCardKeys COMPARE [COMPARE_True],
   compareCardVals COMPARE [COMPARE_True],
   compareSubstackKeys COMPARE [COMPARE_True],
   pointerCardKeys DEREFERENCE [DEREFERENCE_None],
   pointerCardVals DEREFERENCE [DEREFERENCE_None],
   pointerSubstackKeys DEREFERENCE [DEREFERENCE_None],
   compareSubstackAdrs COMPARE [COMPARE_False]
) (stackEqualsOtherStack bool)

func (*Stack) Extract

func (stack *Stack) Extract(arguments ...any) *Card

* Removes and returns a found card, or nil if not found

stack.Extract(
   findType FIND [FIND_Last],
   findData any|[]any|*Stack|func(
     card *Card,
     parentStack *Stack,
     isSubstack bool,
     coords *Stack,
     retStack *Stack,
     retCard *Card,
     retVarPtr any,
     otherInfo []any {
           cardPtr,
           parentStackPtr,
           retStackPtr,
           retCardPtr
     },
     workingMem ...any
   ) [nil],
   deepSearchType DEEPSEARCH [DEEPSEARCH_False],
   depth int|[]int|*Stack [-1],
   passType PASS [PASS_Both],
   dereferenceType DEREFERENCE [DEREFERENCE_None],
   overrideFindData OVERRIDE [OVERRIDE_False],
   workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}]
) (extractedCard *Card)

@ensures
| IF `overrideFindData` == OVERRIDE_True:
|   compare whether each element is equal to `findData` itself, rather than each element inside of `findData` (assuming it is a stack or array)
| IF a version for func input data is passed that has fewer parameters than the full function:
|   the function will abstract away unincluded parameters

func (*Stack) ExtractMany

func (stack *Stack) ExtractMany(arguments ...any) *Stack

* Removes and returns a stack of found cards

stack.ExtractMany(
   findType FIND [FIND_Last],
   findData any|[]any|*Stack|func(
     card *Card,
     parentStack *Stack,
     isSubstack bool,
     coords *Stack,
     retStack *Stack,
     retCard *Card,
     retVarPtr any,
     otherInfo []any {
           cardPtr,
           parentStackPtr,
           retStackPtr,
           retCardPtr
     },
     workingMem ...any
   ) [nil],
   returnType RETURN [RETURN_Cards],
   deepSearchType DEEPSEARCH [DEEPSEARCH_False],
   depth int|[]int|*Stack [-1],
   passType PASS [PASS_Both],
   dereferenceType DEREFERENCE [DEREFERENCE_None],
   overrideFindData OVERRIDE [OVERRIDE_False],
   workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}]
) (extractedData *Stack)

@ensures
| IF `overrideFindData` == OVERRIDE_True:
|   compare whether each element is equal to `findData` itself, rather than each element inside of `findData` (assuming it is a stack or array)
| IF a version for func input data is passed that has fewer parameters than the full function:
|   the function will abstract away unincluded parameters

func (*Stack) Filter

func (stack *Stack) Filter(arguments ...any) *Stack

* Sets `stack` to a set of cards from specified parameters in `stack`, returning `stack`

stack.Filter(
   findType FIND [FIND_All],
   findData any|[]any|*Stack|func(
     card *Card,
     parentStack *Stack,
     isSubstack bool,
     coords *Stack,
     retStack *Stack,
     retCard *Card,
     retVarPtr any,
     otherInfo []any {
           cardPtr,
           parentStackPtr,
           retStackPtr,
           retCardPtr
     },
     workingMem ...any
   ) [nil],
   returnType RETURN [RETURN_Cards],
   deepSearchType DEEPSEARCH [DEEPSEARCH_False],
   depth int|[]int|*Stack [-1],
   passType PASS [PASS_Both],
   dereferenceType DEREFERENCE [DEREFERENCE_None],
   overrideFindData OVERRIDE [OVERRIDE_False],
   workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}]
) (stack)

@ensures
| IF `overrideFindData` == OVERRIDE_True:
|   compare whether each element is equal to `findData` itself, rather than each element inside of `findData` (assuming it is a stack or array)
| IF a version for func input data is passed that has fewer parameters than the full function:
|   the function will abstract away unincluded parameters

func (*Stack) Flip

func (stack *Stack) Flip() *Stack

* Reverses the order of the first immediate cards/substacks in `stack`

stack.Flip() (stack)

func (*Stack) Get

func (stack *Stack) Get(arguments ...any) *Card

* Gets the first card from specified parameters in `stack`, or nil if does not exist

stack.Get(
   findType FIND [FIND_Last],
   findData any|[]any|*Stack|func(
     card *Card,
     parentStack *Stack,
     isSubstack bool,
     coords *Stack,
     retStack *Stack,
     retCard *Card,
     retVarPtr any,
     otherInfo []any {
           cardPtr,
           parentStackPtr,
           retStackPtr,
           retCardPtr
     },
     workingMem ...any
   ) [nil],
   deepSearchType DEEPSEARCH [DEEPSEARCH_False],
   depth int|[]int|*Stack [-1],
   passType PASS [PASS_Both],
   dereferenceType DEREFERENCE [DEREFERENCE_None],
   overrideFindData OVERRIDE [OVERRIDE_False],
   workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}]
) (foundCard *Card)

@ensures
| IF `overrideFindData` == OVERRIDE_True:
|   compare whether each element is equal to `findData` itself, rather than each element inside of `findData` (assuming it is a stack or array)
| IF a version for func input data is passed that has fewer parameters than the full function:
|   the function will abstract away unincluded parameters

func (*Stack) GetMany

func (stack *Stack) GetMany(arguments ...any) *Stack

* Gets a stack of cards from specified parameters in `stack`

stack.GetMany(
   findType FIND [FIND_All],
   findData any|[]any|*Stack|func(
     card *Card,
     parentStack *Stack,
     isSubstack bool,
     coords *Stack,
     retStack *Stack,
     retCard *Card,
     retVarPtr any,
     otherInfo []any {
           cardPtr,
           parentStackPtr,
           retStackPtr,
           retCardPtr
     },
     workingMem ...any
   ) [nil],
   returnType RETURN [RETURN_Cards],
   deepSearchType DEEPSEARCH [DEEPSEARCH_False],
   depth int|[]int|*Stack [-1],
   passType PASS [PASS_Both],
   dereferenceType DEREFERENCE [DEREFERENCE_None],
   overrideFindData OVERRIDE [OVERRIDE_False],
   workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}]
) (newStack *Stack)

@ensures
| IF `overrideFindData` == OVERRIDE_True:
|   compare whether each element is equal to `findData` itself, rather than each element inside of `findData` (assuming it is a stack or array)
| IF a version for func input data is passed that has fewer parameters than the full function:
|   the function will abstract away unincluded parameters

func (*Stack) Has

func (stack *Stack) Has(arguments ...any) bool

* Returns a bool for whether a card was found in `stack`

stack.Has(
   findType FIND [FIND_Last],
   findData any|[]any|*Stack|func(
     card *Card,
     parentStack *Stack,
     isSubstack bool,
     coords *Stack,
     retStack *Stack,
     retCard *Card,
     retVarPtr any,
     otherInfo []any {
           cardPtr,
           parentStackPtr,
           retStackPtr,
           retCardPtr
     },
     workingMem ...any
   ) [nil],
   deepSearchType DEEPSEARCH [DEEPSEARCH_False],
   depth int|[]int|*Stack [-1],
   passType PASS [PASS_Both],
   dereferenceType DEREFERENCE [DEREFERENCE_None],
   overrideFindData OVERRIDE [OVERRIDE_False],
   workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}]
) (foundACard bool)

@ensures
| IF `overrideFindData` == OVERRIDE_True:
|   compare whether each element is equal to `findData` itself, rather than each element inside of `findData` (assuming it is a stack or array)
| IF a version for func input data is passed that has fewer parameters than the full function:
|   the function will abstract away unincluded parameters

func (*Stack) IsRegular

func (stack *Stack) IsRegular() bool

* Returns whether the matrix is of a regular shape

stack.IsRegular() (newStack stack)

@examples
| MakeStack([]*Stack {MakeSubstack([]int {1, 2}), MakeSubstack([]int {3, 4}), MakeSubstack([]int {5, 6})}) => true
| MakeStack([]*Stack {MakeSubstack([]int {1, 2}), MakeSubstack([]int {3, 4, 5}), MakeSubstack([]int {6, 7})}) => false

func (*Stack) Lambda

func (stack *Stack) Lambda(lambda any, arguments ...any) (*Stack, *Stack, *Card, any)

* Iterates through `stack` calling your lambda function on each card, returning `stack`, `retStack`, `retCard`, and `retVarPtr`

 stack.Lambda(
    lambda func(
        card *Card,
        parentStack *Stack,
        isSubstack bool,
        coords *Stack,
        retStack *Stack,
        retCard *Card,
        retVarPtr any,
        otherInfo []any {
            cardPtr,
            parentStackPtr,
            retStackPtr,
            retCardPtr
		},
        workingMem ...any),
    retStack *Stack [nil],
    retCard *Card [nil],
    retVarPtr any [nil],
    workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}],
    deepSearchType DEEPSEARCH [DEEPSEARCH_True],
    depth int|[]int|*Stack [-1],
    passType PASS [PASS_Both],
    otherInfo []any {
        retStackPtr,
        retCardPtr
    } []any [[]any {nil, nil}],
 ) (stack, retStack, retCard, retVarPtr)

 @ensures
 | IF a version for `lambda` is passed that has fewer parameters than the full function:
 |   the function will abstract away unincluded parameters
 | IF you would like to manage more than 10 variables via `workingMem`:
 |   you must pass an []any array into `workingMem` when you call this function
 | IF you would like to reference the object address of `retStack` or `retCard`:
 |   pass the addresses of `retStack` or `retCard` into `otherInfo`
 @examples
 | myStack := MakeStackMatrix([]int {1, 3, 2, 4}, nil, []int {2, 2}).LambdaThis(func(card *Card) {
 |   if card.Idx == 0 && card.Val.(int) % 2 == 0 {
 |     card.Key = "Marker"
 |   }
 | }) // Stack{nil:1, nil:3, "Marker":2, nil:4}

func (*Stack) LambdaCard

func (stack *Stack) LambdaCard(lambda any, arguments ...any) *Card

* Iterates through `stack` calling your lambda function on each card, returning `stack`, `retStack`, `retCard`, and `retVarPtr`

 stack.LambdaCard(
    lambda func(
        card *Card,
        parentStack *Stack,
        isSubstack bool,
        coords *Stack,
        retStack *Stack,
        retCard *Card,
        retVarPtr any,
        otherInfo []any {
            cardPtr,
            parentStackPtr,
            retStackPtr,
            retCardPtr
		},
        workingMem ...any),
    retStack *Stack [nil],
    retCard *Card [nil],
    retVarPtr any [nil],
    workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}],
    deepSearchType DEEPSEARCH [DEEPSEARCH_True],
    depth int|[]int|*Stack [-1],
    passType PASS [PASS_Both],
    otherInfo []any {
        retStackPtr,
        retCardPtr
    } []any [[]any {nil, nil}],
 ) (retCard)

 @ensures
 | IF a version for `lambda` is passed that has fewer parameters than the full function:
 |   the function will abstract away unincluded parameters
 | IF you would like to manage more than 10 variables via `workingMem`:
 |   you must pass an []any array into `workingMem` when you call this function
 | IF you would like to reference the object address of `retStack` or `retCard`:
 |   pass the addresses of `retStack` or `retCard` into `otherInfo`
 @examples
 | myStack := MakeStackMatrix([]int {1, 3, 2, 4}, nil, []int {2, 2}).LambdaThis(func(card *Card) {
 |   if card.Idx == 0 && card.Val.(int) % 2 == 0 {
 |     card.Key = "Marker"
 |   }
 | }) // Stack{nil:1, nil:3, "Marker":2, nil:4}

func (*Stack) LambdaStack

func (stack *Stack) LambdaStack(lambda any, arguments ...any) *Stack

* Iterates through `stack` calling your lambda function on each card, returning `stack`, `retStack`, `retCard`, and `retVarPtr`

 stack.LambdaStack(
    lambda func(
        card *Card,
        parentStack *Stack,
        isSubstack bool,
        coords *Stack,
        retStack *Stack,
        retCard *Card,
        retVarPtr any,
        otherInfo []any {
            cardPtr,
            parentStackPtr,
            retStackPtr,
            retCardPtr
		},
        workingMem ...any),
    retStack *Stack [nil],
    retCard *Card [nil],
    retVarPtr any [nil],
    workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}],
    deepSearchType DEEPSEARCH [DEEPSEARCH_True],
    depth int|[]int|*Stack [-1],
    passType PASS [PASS_Both],
    otherInfo []any {
        retStackPtr,
        retCardPtr
    } []any [[]any {nil, nil}],
 ) (retStack)

 @ensures
 | IF a version for `lambda` is passed that has fewer parameters than the full function:
 |   the function will abstract away unincluded parameters
 | IF you would like to manage more than 10 variables via `workingMem`:
 |   you must pass an []any array into `workingMem` when you call this function
 | IF you would like to reference the object address of `retStack` or `retCard`:
 |   pass the addresses of `retStack` or `retCard` into `otherInfo`
 @examples
 | myStack := MakeStackMatrix([]int {1, 3, 2, 4}, nil, []int {2, 2}).LambdaThis(func(card *Card) {
 |   if card.Idx == 0 && card.Val.(int) % 2 == 0 {
 |     card.Key = "Marker"
 |   }
 | }) // Stack{nil:1, nil:3, "Marker":2, nil:4}

func (*Stack) LambdaThis

func (stack *Stack) LambdaThis(lambda any, arguments ...any) *Stack

* Iterates through `stack` calling your lambda function on each card, returning `stack`, `retStack`, `retCard`, and `retVarPtr`

 stack.LambdaThis(
    lambda func(
        card *Card,
        parentStack *Stack,
        isSubstack bool,
        coords *Stack,
        retStack *Stack,
        retCard *Card,
        retVarPtr any,
        otherInfo []any {
            cardPtr,
            parentStackPtr,
            retStackPtr,
            retCardPtr
		},
        workingMem ...any),
    retStack *Stack [nil],
    retCard *Card [nil],
    retVarPtr any [nil],
    workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}],
    deepSearchType DEEPSEARCH [DEEPSEARCH_True],
    depth int|[]int|*Stack [-1],
    passType PASS [PASS_Both],
    otherInfo []any {
        retStackPtr,
        retCardPtr
    } []any [[]any {nil, nil}],
 ) (stack)

 @ensures
 | IF a version for `lambda` is passed that has fewer parameters than the full function:
 |   the function will abstract away unincluded parameters
 | IF you would like to manage more than 10 variables via `workingMem`:
 |   you must pass an []any array into `workingMem` when you call this function
 | IF you would like to reference the object address of `retStack` or `retCard`:
 |   pass the addresses of `retStack` or `retCard` into `otherInfo`
 @examples
 | myStack := MakeStackMatrix([]int {1, 3, 2, 4}, nil, []int {2, 2}).LambdaThis(func(card *Card) {
 |   if card.Idx == 0 && card.Val.(int) % 2 == 0 {
 |     card.Key = "Marker"
 |   }
 | }) // Stack{nil:1, nil:3, "Marker":2, nil:4}

func (*Stack) LambdaVarAdr

func (stack *Stack) LambdaVarAdr(lambda any, arguments ...any) any

* Iterates through `stack` calling your lambda function on each card, returning `stack`, `retStack`, `retCard`, and `retVarPtr`

 stack.LambdaVarAdr(
    lambda func(
        card *Card,
        parentStack *Stack,
        isSubstack bool,
        coords *Stack,
        retStack *Stack,
        retCard *Card,
        retVarPtr any,
        otherInfo []any {
            cardPtr,
            parentStackPtr,
            retStackPtr,
            retCardPtr
		},
        workingMem ...any),
    retStack *Stack [nil],
    retCard *Card [nil],
    retVarPtr any [nil],
    workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}],
    deepSearchType DEEPSEARCH [DEEPSEARCH_True],
    depth int|[]int|*Stack [-1],
    passType PASS [PASS_Both],
    otherInfo []any {
        retStackPtr,
        retCardPtr
    } []any [[]any {nil, nil}],
 ) (retVarPtr)

 @ensures
 | IF a version for `lambda` is passed that has fewer parameters than the full function:
 |   the function will abstract away unincluded parameters
 | IF you would like to manage more than 10 variables via `workingMem`:
 |   you must pass an []any array into `workingMem` when you call this function
 | IF you would like to reference the object address of `retStack` or `retCard`:
 |   pass the addresses of `retStack` or `retCard` into `otherInfo`
 @examples
 | myStack := MakeStackMatrix([]int {1, 3, 2, 4}, nil, []int {2, 2}).LambdaThis(func(card *Card) {
 |   if card.Idx == 0 && card.Val.(int) % 2 == 0 {
 |     card.Key = "Marker"
 |   }
 | }) // Stack{nil:1, nil:3, "Marker":2, nil:4}

func (*Stack) Move

func (stack *Stack) Move(arguments ...any) *Stack

* Moves one card to before/after another card and returns `stack`

stack.Move(
   orderType ORDER [ORDER_After],
   findTypeFrom FIND [FIND_First],
   findTypeTo FIND [FIND_Last],
   findDataFrom any|[]any|*Stack|func(
     card *Card,
     parentStack *Stack,
     isSubstack bool,
     coords *Stack,
     retStack *Stack,
     retCard *Card,
     retVarPtr any,
     otherInfo []any {
           cardPtr,
           parentStackPtr,
           retStackPtr,
           retCardPtr
     },
     workingMem ...any
   ) [nil],
   findDataTo any|[]any|*Stack|func(
     card *Card,
     parentStack *Stack,
     isSubstack bool,
     coords *Stack,
     retStack *Stack,
     retCard *Card,
     retVarPtr any,
     otherInfo []any {
           cardPtr,
           parentStackPtr,
           retStackPtr,
           retCardPtr
     },
     workingMem ...any
   ) [nil],
   deepSearchTypeFrom DEEPSEARCH [DEEPSEARCH_False],
   deepSearchTypeTo DEEPSEARCH [DEEPSEARCH_False],
   depthFrom int [-1],
   depthTo int [-1],
   passTypeFrom PASS [PASS_Both],
   passTypeTo PASS [PASS_Both],
   dereferenceTypeFrom DEREFERENCE [DEREFERENCE_None],
   dereferenceTypeTo DEREFERENCE [DEREFERENCE_None],
   overrideFindDataFrom OVERRIDE [OVERRIDE_False],
   overrideFindDataTo OVERRIDE [OVERRIDE_False],
   workingMemFrom []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}]
   workingMemTo []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}]
) (stack)

@ensures
| IF `overrideFindDataX` == OVERRIDE_True:
|   compare whether each element is equal to `findDataX` itself, rather than each element inside of `findDataX` (assuming it is a stack or array)
| IF a version for func input data is passed that has fewer parameters than the full function:
|   the function will abstract away unincluded parameters

func (*Stack) Print

func (stack *Stack) Print(arguments ...any) *Stack

* Prints information surrounding `stack` to the terminal and returns `stack`

stack.Print(indent int [0]) (stack)

@ensures
| prints "-" `indent` * 4 times before each line to indicate depth in a stackMatrix
@examples
| MakeStack([]string {"Hey", "Hi"}).Print().Remove(FIND_Last).Print() // prints the stack before and after performing the remove function

func (*Stack) Remove

func (stack *Stack) Remove(arguments ...any) *Stack

* Removes a card from and returns `stack`

stack.Remove(
   findType FIND [FIND_Last],
   findData any|[]any|*Stack|func(
     card *Card,
     parentStack *Stack,
     isSubstack bool,
     coords *Stack,
     retStack *Stack,
     retCard *Card,
     retVarPtr any,
     otherInfo []any {
           cardPtr,
           parentStackPtr,
           retStackPtr,
           retCardPtr
     },
     workingMem ...any
   ) [nil],
   deepSearchType DEEPSEARCH [DEEPSEARCH_False],
   depth int|[]int|*Stack [-1],
   passType PASS [PASS_Both],
   dereferenceType DEREFERENCE [DEREFERENCE_None],
   overrideFindData OVERRIDE [OVERRIDE_False],
   workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}]
) (stack)

@ensures
| IF `overrideFindData` == OVERRIDE_True:
|   compare whether each element is equal to `findData` itself, rather than each element inside of `findData` (assuming it is a stack or array)
| IF a version for func input data is passed that has fewer parameters than the full function:
|   the function will abstract away unincluded parameters

func (*Stack) RemoveMany

func (stack *Stack) RemoveMany(arguments ...any) *Stack

* Removes a set of cards from and returns `stack`

stack.RemoveMany(
   findType FIND [FIND_All],
   findData any|[]any|*Stack|func(
     card *Card,
     parentStack *Stack,
     isSubstack bool,
     coords *Stack,
     retStack *Stack,
     retCard *Card,
     retVarPtr any,
     otherInfo []any {
           cardPtr,
           parentStackPtr,
           retStackPtr,
           retCardPtr
     },
     workingMem ...any
   ) [nil],
   deepSearchType DEEPSEARCH [DEEPSEARCH_False],
   depth int|[]int|*Stack [-1],
   passType PASS [PASS_Both],
   dereferenceType DEREFERENCE [DEREFERENCE_None],
   overrideFindData OVERRIDE [OVERRIDE_False],
   workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}]
) (stack)

@ensures
| IF `overrideFindData` == OVERRIDE_True:
|   compare whether each element is equal to `findData` itself, rather than each element inside of `findData` (assuming it is a stack or array)
| IF a version for func input data is passed that has fewer parameters than the full function:
|   the function will abstract away unincluded parameters

func (*Stack) Replace

func (stack *Stack) Replace(replaceType REPLACE, replaceWith any, arguments ...any) *Card
  • Returns a clone of the first found card from specified parameters in `stack` stack.Replace( replaceType REPLACE, replaceWith any|[]any|*Stack|func( card *Card, parentStack *Stack, isSubstack bool, coords *Stack, workingMem ...any, ), findType FIND FIND_Last, findData any|[]any|*Stack|func( card *Card, parentStack *Stack, isSubstack bool, coords *Stack, retStack *Stack, retCard *Card, retVarPtr any, otherInfo []any { cardPtr, parentStackPtr, retStackPtr, retCardPtr }, workingMem ...any ) [nil], deepSearchType DEEPSEARCH DEEPSEARCH_False, depth int|[]int|*Stack [-1], passType PASS PASS_Both, dereferenceType DEREFERENCE DEREFERENCE_None, overrideFindData OVERRIDE OVERRIDE_False, workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}] ) (replacedCard *Card)

    @ensures | IF `overrideFindData` == OVERRIDE_True: | compare whether each element is equal to `findData` itself, rather than each element inside of `findData` (assuming it is a stack or array) | IF a version for func input data is passed that has fewer parameters than the full function: | the function will abstract away unincluded parameters

func (*Stack) ReplaceMany

func (stack *Stack) ReplaceMany(replaceType REPLACE, replaceWith any, arguments ...any) *Stack
  • Returns a stack of clones of the found cards from specified parameters in `stack` stack.ReplaceMany( replaceType REPLACE, replaceWith any|[]any|*Stack|func( card *Card, parentStack *Stack, isSubstack bool, coords *Stack, workingMem ...any, ), findType FIND FIND_Last, findData any|[]any|*Stack|func( card *Card, parentStack *Stack, isSubstack bool, coords *Stack, retStack *Stack, retCard *Card, retVarPtr any, otherInfo []any { cardPtr, parentStackPtr, retStackPtr, retCardPtr }, workingMem ...any ) [nil], returnType RETURN RETURN_Cards, deepSearchType DEEPSEARCH DEEPSEARCH_False, depth int|[]int|*Stack [-1], passType PASS PASS_Both, dereferenceType DEREFERENCE DEREFERENCE_None, overrideFindData OVERRIDE OVERRIDE_False, workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}] ) (replacedCards *Stack)

    @ensures | IF `overrideFindData` == OVERRIDE_True: | compare whether each element is equal to `findData` itself, rather than each element inside of `findData` (assuming it is a stack or array) | IF a version for func input data is passed that has fewer parameters than the full function: | the function will abstract away unincluded parameters

func (*Stack) Shape

func (stack *Stack) Shape() *Stack

* Returns an array representing the shape of `stack`

stack.Shape() (newStack stack)

@ensures
| returns nil if it's not regular and thus doesn't have a shape
@examples
| MakeStack([]*Stack {MakeSubstack([]int {1, 2, 3}), MakeSubstack([]int {4, 5, 6})}).Shape() => []int {2, 3}
| MakeStack([]*Stack {MakeSubstack([]int {1, 2}), MakeSubstack([]int {3, 4}), MakeSubstack([]int {5, 6})}).Shape() => []int {3, 2}
| MakeStack([]*Stack {MakeSubstack([]int {1, 2}), MakeSubstack([]int {3, 4, 5}), MakeSubstack([]int {6, 7})}) => nil

func (*Stack) Shuffle

func (stack *Stack) Shuffle(arguments ...any) *Stack

* Shuffles the order of `stack` cards

stack.Shuffle(repeatType REPEAT [REPEAT_False]) (stack)

@ensures
| IF `repeatType` == true AND stack.Size > 1:
|   shuffles `stack` until it is no longer in its previous order
| rand.Seed is updated to time.Now().UnixNano()

func (*Stack) Swap

func (stack *Stack) Swap(arguments ...any) *Stack

* Swaps one card with another and returns `stack`

stack.Swap(
   findType1 FIND [FIND_First],
   findType2 FIND [FIND_Last],
   findData1 any|[]any|*Stack|func(
     card *Card,
     parentStack *Stack,
     isSubstack bool,
     coords *Stack,
     retStack *Stack,
     retCard *Card,
     retVarPtr any,
     otherInfo []any {
           cardPtr,
           parentStackPtr,
           retStackPtr,
           retCardPtr
     },
     workingMem ...any
   ) [nil],
   findData2 any|[]any|*Stack|func(
     card *Card,
     parentStack *Stack,
     isSubstack bool,
     coords *Stack,
     retStack *Stack,
     retCard *Card,
     retVarPtr any,
     otherInfo []any {
           cardPtr,
           parentStackPtr,
           retStackPtr,
           retCardPtr
     },
     workingMem ...any
   ) [nil],
   deepSearchType1 DEEPSEARCH [DEEPSEARCH_False],
   deepSearchType2 DEEPSEARCH [DEEPSEARCH_False],
   depth1 int [-1],
   depth2 int [-1],
   passType1 PASS [PASS_Both],
   passType2 PASS [PASS_Both],
   dereferenceType1 DEREFERENCE [DEREFERENCE_None],
   dereferenceType2 DEREFERENCE [DEREFERENCE_None],
   overrideFindData1 OVERRIDE [OVERRIDE_False],
   overrideFindData2 OVERRIDE [OVERRIDE_False],
   workingMem1 []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}]
   workingMem2 []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}]
) (stack)

@ensures
| IF `overrideFindDataX` == OVERRIDE_True:
|   compare whether each element is equal to `findDataX` itself, rather than each element inside of `findDataX` (assuming it is a stack or array)
| IF a version for func input data is passed that has fewer parameters than the full function:
|   the function will abstract away unincluded parameters

func (*Stack) SwitchKeysVals

func (stack *Stack) SwitchKeysVals(arguments ...any) *Stack

* Switches the Key and the Val of each found card and returns `stack`

 stack.SwitchKeysVals(
   findType FIND [FIND_All],
   findData any|[]any|*Stack|func(
     card *Card,
     parentStack *Stack,
     isSubstack bool,
     coords *Stack,
     retStack *Stack,
     retCard *Card,
     retVarPtr any,
     otherInfo []any {
           cardPtr,
           parentStackPtr,
           retStackPtr,
           retCardPtr
     },
     workingMem ...any
   ) [nil],
   deepSearchType DEEPSEARCH [DEEPSEARCH_False],
   depth int|[]int|*Stack [-1],
   dereferenceType DEREFERENCE [DEREFERENCE_None],
   overrideFindData OVERRIDE [OVERRIDE_False],
   workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}]
) (stack)

@ensures
| IF `overrideFindData` == OVERRIDE_True:
|   compare whether each element is equal to `findData` itself, rather than each element inside of `findData` (assuming it is a stack or array)
| IF a version for func input data is passed that has fewer parameters than the full function:
|   the function will abstract away unincluded parameters

func (*Stack) ToArray

func (stack *Stack) ToArray(arguments ...any) []any

* Creates a new any array whose elements are the values of the cards in `stack`

stack.ToArray(returnType RETURN [RETURN_Vals]) (newArray []any)

@examples
| MakeStack([]int {1, 2, 3}, []string {"a", "b", "c"}).ToArray() => []any {1, 2, 3}
| MakeStack([]int {1, 2, 3}, []string {"a", "b", "c"}).ToArray(RETURN_Keys) => []any {"a", "b", "c"}
| MakeStack([]int {1, 2, 3}, []string {"a", "b", "c"}).ToArray(RETURN_Idxs) => []any {0, 1, 2}
| MakeStack([]*Card {cardA, cardB, cardC}).ToArray(RETURN_Cards) => []any {cardA, cardB, cardC}
| MakeStack([]*Stack {substackA, substackB}).ToArray(RETURN_Cards) => []any {Card{Val:substackA}, Card{Val:substackA}}
| MakeStack([]*Stack {substackA, substackB}).ToArray(RETURN_Stacks) => []any {substackA, substackB}

func (*Stack) ToCSV

func (stack *Stack) ToCSV(outPath string) *os.File

* Creates a CSV at a given file path given a StackMatrix

stack.ToCSV(outPath string) (csvFile *os.File)

@requires
| `outPath` points to valid location

func (*Stack) ToMap

func (stack *Stack) ToMap() map[any]any

* Creates a new map whose keys and values correspond to the cards in `stack`

stack.ToMap() (newMap map[any]any)

@examples
| MakeStack([]int {1, 2, 3}, []string {"a", "b", "c"}).ToMap() => map[any]any {1:"a", 2:"b", 3:"c"} // in any order

func (*Stack) ToMatrix

func (stack *Stack) ToMatrix(arguments ...any) []any

* Creates a new matrix structure from `stack`

stack.ToMatrix(returnType RETURN [RETURN_Vals], depth int [-1]) (newMatrix []any {elem/[]any{}})

@examples
| MakeStack([]int {1, 2, 3, 4}).ToMatrix() => []any {1, 2, 3, 4}
| MakeStack(*Stack{MakeSubstack([]int {1, 2}), MakeSubstack([]int {3, 4})}).ToMatrix() => []any {[]any {1, 2}, []any {3, 4}}

func (*Stack) Transpose added in v1.0.5

func (stack *Stack) Transpose() *Stack

* Updates `stack` to its transpose, or returns nil if `stack` is of irregular shape

stack.Transpose() (stack)

@examples
| MakeStackMatrix([]int {1, 2, 3, 4, 5, 6}, nil, []int {2, 3}).Transpose() => Stack {Stack{1, 4}, Stack{2, 5}, Stack{3, 6}}

func (*Stack) Unique

func (stack *Stack) Unique(arguments ...any) *Stack

* Removes all cards from `stack` which share a given property as another card in that stack

stack.Unique(uniqueType TYPE [TYPE_Val], dereferenceType DEREFERENCE [DEREFERENCE_None]) (stack)

@examples
| MakeStack([]int {1, 2, 3, 1, 2, 4}).Unique() // Stack{1, 2, 3, 4}
| MakeStack([]int {0, 1, 0, 0, 1, 0}, []int {1, 2, 3, 1, 2, 4}).Unique(TYPE_Key) // Stack{1, 2}

func (*Stack) Update

func (stack *Stack) Update(replaceType REPLACE, replaceWith any, arguments ...any) *Stack

* Updates a card in and returns `stack`

stack.Update(
   replaceType REPLACE,
   replaceWith any|[]any|*Stack|func(
       card *Card,
       parentStack *Stack,
       isSubstack bool,
       coords *Stack,
       workingMem ...any,
   ),
   findType FIND [FIND_Last],
   findData any|[]any|*Stack|func(
     card *Card,
     parentStack *Stack,
     isSubstack bool,
     coords *Stack,
     retStack *Stack,
     retCard *Card,
     retVarPtr any,
     otherInfo []any {
           cardPtr,
           parentStackPtr,
           retStackPtr,
           retCardPtr
     },
     workingMem ...any
   ) [nil],
   deepSearchType DEEPSEARCH [DEEPSEARCH_False],
   depth int|[]int|*Stack [-1],
   passType PASS [PASS_Both],
   dereferenceType DEREFERENCE [DEREFERENCE_None],
   overrideFindData OVERRIDE [OVERRIDE_False],
   workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}]
) (stack)

@ensures
| IF `overrideFindData` == OVERRIDE_True:
|   compare whether each element is equal to `findData` itself, rather than each element inside of `findData` (assuming it is a stack or array)
| IF a version for func input data is passed that has fewer parameters than the full function:
|   the function will abstract away unincluded parameters

func (*Stack) UpdateMany

func (stack *Stack) UpdateMany(replaceType REPLACE, replaceWith any, arguments ...any) *Stack

* Updates all matched cards in and returns `stack`

stack.UpdateMany(
   replaceType REPLACE,
   replaceWith any|[]any|*Stack|func(
       card *Card,
       parentStack *Stack,
       isSubstack bool,
       coords *Stack,
       workingMem ...any,
   ),
   findType FIND [FIND_Last],
   findData any|[]any|*Stack|func(
     card *Card,
     parentStack *Stack,
     isSubstack bool,
     coords *Stack,
     retStack *Stack,
     retCard *Card,
     retVarPtr any,
     otherInfo []any {
           cardPtr,
           parentStackPtr,
           retStackPtr,
           retCardPtr
     },
     workingMem ...any
   ) [nil],
   deepSearchType DEEPSEARCH [DEEPSEARCH_False],
   depth int|[]int|*Stack [-1],
   passType PASS [PASS_Both],
   dereferenceType DEREFERENCE [DEREFERENCE_None],
   overrideFindData OVERRIDE [OVERRIDE_False],
   workingMem []any [[]any {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}]
) (stack)

 Updates all matched cards in and returns `stack`

@ensures
| IF `overrideFindData` == OVERRIDE_True:
|   compare whether each element is equal to `findData` itself, rather than each element inside of `findData` (assuming it is a stack or array)
| IF a version for func input data is passed that has fewer parameters than the full function:
|   the function will abstract away unincluded parameters

type TYPE

type TYPE int
const (
	TYPE_Key TYPE = iota
	TYPE_Val
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL