I gather that in Rebol one is expected to use a block for representing arbitrary structured data. Are there built-in or standard ways of treating blocks as data structures other than lists?
I am thinking of:
- stacks
- queues (possibly double-ended)
- sets
- maps aka. associative arrays
Rebol have three holders of arbitrary data that all can be treated the same way.
You operate on them in the same way with
but they differ a little in result and particularly in response time.
In your case use
As mentioned all operate similarly (even the hash! can be referenced by index). Hence you can treat any of them as an associative array.
which would result in exactly the same for a hash! defined as
x: hash! [a 1 b 2 33]
. So to add a new key value pair:Note that rebol does not have a sense of key value pairs, the hash! is just a list of ordered values that internally will build hash! values for referencing. You can therefore just as well ask what follows the value 33 above
To really use it for key value pairs, use the skip refinement
For the associative arrays you can also use object! in case it does not need to have dynamic fields.