Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
45
Task/Arrays/Plain-English/arrays.plain
Normal file
45
Task/Arrays/Plain-English/arrays.plain
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
To run:
|
||||
Start up.
|
||||
Write "Creating an array of 100 numbers..." on the console.
|
||||
Create a number array given 100.
|
||||
Write "Putting 1 into the array at index 0." on the console.
|
||||
Put 1 into the number array at 0.
|
||||
Write "Putting 33 into the array at index 50." on the console.
|
||||
Put 33 into the number array at 50.
|
||||
Write "Retrieving value from array at index 0... " on the console without advancing.
|
||||
Get a number from the number array at 0.
|
||||
Write "" then the number on the console.
|
||||
Write "Retrieving value from array at index 50... " on the console without advancing.
|
||||
Get another number from the number array at 50.
|
||||
Write "" then the other number on the console.
|
||||
Write "Retrieving value from array at index 99... " on the console without advancing.
|
||||
Get a third number from the number array at 99.
|
||||
Write "" then the third number on the console.
|
||||
Destroy the number array.
|
||||
Wait for the escape key.
|
||||
Shut down.
|
||||
|
||||
\\\\\\\\\\\\\\\\\\ Array implementation \\\\\\\\\\\\\\\\\\\\
|
||||
|
||||
A number array has a first element pointer.
|
||||
|
||||
A location is a number.
|
||||
|
||||
To create a number array given a count:
|
||||
Put a number's magnitude times the count into a size.
|
||||
Assign the number array's first element pointer given the size. \ allocate memory for the array
|
||||
|
||||
To destroy a number array:
|
||||
Unassign the number array's first element pointer. \ free the array's memory
|
||||
|
||||
To get a number from a number array at a location:
|
||||
Put the location times the number's magnitude into an offset.
|
||||
Put the number array's first element pointer into a number pointer.
|
||||
Add the offset to the number pointer.
|
||||
Put the number pointer's target into the number.
|
||||
|
||||
To put a number into a number array at a location:
|
||||
Put the location times the number's magnitude into an offset.
|
||||
Put the number array's first element pointer into a number pointer.
|
||||
Add the offset to the number pointer.
|
||||
Put the number into the number pointer's target.
|
||||
Loading…
Add table
Add a link
Reference in a new issue