Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,30 @@
|
|||
prompt = proc (s: string) returns (int)
|
||||
stream$puts(stream$primary_output(), s)
|
||||
return(int$parse(stream$getl(stream$primary_input())))
|
||||
end prompt
|
||||
|
||||
start_up = proc ()
|
||||
po: stream := stream$primary_output()
|
||||
|
||||
% Ask for width and height
|
||||
width: int := prompt("Width? ")
|
||||
height: int := prompt("Height? ")
|
||||
|
||||
% Create an array of arrays.
|
||||
% In order to actually create separate arrays, rather than repeating
|
||||
% a reference to the same array over and over, fill_copy must be used.
|
||||
arr: array[array[int]] :=
|
||||
array[array[int]]$fill_copy(1, width, array[int]$fill(1, height, 0))
|
||||
|
||||
% Set a value
|
||||
x: int := 1+width/2
|
||||
y: int := 1+height/2
|
||||
arr[x][y] := 123
|
||||
|
||||
% Retrieve the value
|
||||
stream$putl(po, "arr[" || int$unparse(x) || "][" || int$unparse(y)
|
||||
|| "] = " || int$unparse(arr[x][y]))
|
||||
|
||||
% The array will be automatically garbage-collected once there
|
||||
% are no more references to it.
|
||||
end start_up
|
||||
Loading…
Add table
Add a link
Reference in a new issue