Documentation ¶
Index ¶
- type CLONE
- type COMPARE
- type Card
- type DEEPSEARCH
- type DEREFERENCE
- type FIND
- type ORDER
- type OVERRIDE
- type PASS
- type REPEAT
- type REPLACE
- type RETURN
- type Stack
- func (stack *Stack) Add(insert any, arguments ...any) *Stack
- func (stack *Stack) AddMany(insert any, arguments ...any) *Stack
- func (stack *Stack) Clone(arguments ...any) *Stack
- func (stack *Stack) Coordinates(arguments ...any) *Stack
- func (stack *Stack) CoordinatesMany(arguments ...any) *Stack
- func (stack *Stack) DimensionalityReduce(arguments ...any) *Stack
- func (stack *Stack) Duplicate(arguments ...any) *Stack
- func (stack *Stack) Empty() *Stack
- func (stack *Stack) Equals(otherStack *Stack, arguments ...any) (test bool)
- func (stack *Stack) Extract(arguments ...any) *Card
- func (stack *Stack) ExtractMany(arguments ...any) *Stack
- func (stack *Stack) Filter(arguments ...any) *Stack
- func (stack *Stack) Flip() *Stack
- func (stack *Stack) Get(arguments ...any) *Card
- func (stack *Stack) GetMany(arguments ...any) *Stack
- func (stack *Stack) Has(arguments ...any) bool
- func (stack *Stack) IsRegular() bool
- func (stack *Stack) Lambda(lambda any, arguments ...any) (*Stack, *Stack, *Card, any)
- func (stack *Stack) LambdaCard(lambda any, arguments ...any) *Card
- func (stack *Stack) LambdaStack(lambda any, arguments ...any) *Stack
- func (stack *Stack) LambdaThis(lambda any, arguments ...any) *Stack
- func (stack *Stack) LambdaVarAdr(lambda any, arguments ...any) any
- func (stack *Stack) Move(arguments ...any) *Stack
- func (stack *Stack) Print(arguments ...any) *Stack
- func (stack *Stack) Remove(arguments ...any) *Stack
- func (stack *Stack) RemoveMany(arguments ...any) *Stack
- func (stack *Stack) Replace(replaceType REPLACE, replaceWith any, arguments ...any) *Card
- func (stack *Stack) ReplaceMany(replaceType REPLACE, replaceWith any, arguments ...any) *Stack
- func (stack *Stack) Shape() *Stack
- func (stack *Stack) Shuffle(arguments ...any) *Stack
- func (stack *Stack) Swap(arguments ...any) *Stack
- func (stack *Stack) SwitchKeysVals(arguments ...any) *Stack
- func (stack *Stack) ToArray(arguments ...any) []any
- func (stack *Stack) ToCSV(outPath string) *os.File
- func (stack *Stack) ToMap() map[any]any
- func (stack *Stack) ToMatrix(arguments ...any) []any
- func (stack *Stack) Transpose() *Stack
- func (stack *Stack) Unique(arguments ...any) *Stack
- func (stack *Stack) Update(replaceType REPLACE, replaceWith any, arguments ...any) *Stack
- func (stack *Stack) UpdateMany(replaceType REPLACE, replaceWith any, arguments ...any) *Stack
- type TYPE
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Card ¶
func MakeCard ¶
* 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) Equals ¶
* 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 ¶
* 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
type DEREFERENCE ¶
type DEREFERENCE int
const ( DEREFERENCE_None DEREFERENCE = iota DEREFERENCE_Both DEREFERENCE_Found DEREFERENCE_This )
type Stack ¶
func CSVToStackMatrix ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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
* 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 ¶
* 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) Equals ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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 ¶
* Reverses the order of the first immediate cards/substacks in `stack`
stack.Flip() (stack)
func (*Stack) Get ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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 ¶
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 ¶
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 ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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 ¶
* 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
* 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 ¶
* 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 ¶
* 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 ¶
* 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