[REBOL] Re: Newbie query on array indexing
From: brett:codeconscious at: 22-Nov-2001 10:43
Hi,
First off creating the array "example-array" is done like this:
example-array: array 10
This gives you 10 NONEs in a block. To get an array of 10 zeroes use:
example-array: array/initial 10 0
And a side issue (heads up). You are going to get caught if you think you
will get ten different strings with this - you actually get ten references
to the same string:
example-array: array/initial 10 ""
insert example-array/1 "test"
probe example-array
Now for indexing into the array.
If I use a subscript "indx" here are some methods to access the array:
example-array: array/initial 10 0
poke example-array indx 42
example-array/:indx
pick example-array indx
And as Gregg showed you can use the normal series functions. Because
actually ARRAY is a function that
returns a block.
>> type? array 3
== block!
Brett.