RosettaCodeData/Task/Arrays/8th/arrays.8th

15 lines
389 B
Plaintext

[ 1 , 2 ,3 ] \ an array holding three numbers
1 a:@ \ this will be '2', the element at index 1
drop
1 123 a:@ \ this will store the value '123' at index 1, so now
. \ will print [1,123,3]
[1,2,3] 45 a:push
\ gives us [1,2,3,45]
\ and empty spots are filled with null:
[1,2,3] 5 15 a:!
\ gives [1,2,3,null,15]
\ arrays don't have to be homogenous:
[1,"one", 2, "two"]