Skip to content
This repository was archived by the owner on Feb 23, 2018. It is now read-only.
This repository was archived by the owner on Feb 23, 2018. It is now read-only.

Arrays #1

@skyem123

Description

@skyem123

In this, an array will be a stack element, that can hold an arbitary amount of items of a specified type.
Interestingly / hopefully, most of the time, the array wouldn't acutally need to be poped, just editied in place most of the time.

To create these arrays, use the instruction carr (create array), and the number at the top of the stack, will be used as the number of elements. If the stack contains A, B, C, D, E then the array would be A long with B, C, D, E as the elements, with B being at 0 and E being at 3. (pops the item number and items, then pushes an array)

There will also be rarr (reverse array), which reverses an array. For example the array containting elements of B, C, D, E will be converted to E, C, D, B, with E being at 0 and B being at 3. (pops an array, then pushes a reversed array.

cbar (create blank array) will create a blank array, poping a number from the stack that specifies the length. (pops the size of the array, then pushses a blank array)

sare (set array element) will set an element in an array. on the top of the stack will be the element to put onto the array, and below that will be the index to set it at, and below that will be the array. (pops the element, index, and array, then pushes the modified array).

gare (get array element) will get an element from the array, on top of the stack should be the index, and below that should be the array. after this operation the element should be on top of the stack, with the non-modified array below it. (pops the idex and array, then pushes the element and array).

garl (get array length) will get the length of an array. (pop array, then push array, then length)

gart (get array type) will get the type of the array (pop array, then push array, then type)

darr (deconstruct array) is the opposite of carr. If the stack an array of B, C, D, E with size of A, then it would have A on the top of the stack, followed by B, C, D, E. (pop array, then push elements in array, then length of array)

also, another instruction should be added, swpm (swap many), will swap stack entries given an amount of entries to swap, similar to rarr. If the stack contains A, B, C, D, E, and A is 3, after the instruction, the stack would contain D, C, B, E.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions