Hi Petr,
You wrote:
>Could anyone elaborate on following, please?
>
>->> ar: array/initial [3 4] copy ""
>== [["" "" "" ""] ["" "" "" ""] ["" "" "" ""]]
>->> change ar/1/1 "adfaf"
>== ""
>->> ar
>== [["adfaf" "adfaf" "adfaf" "adfaf"] ["adfaf" "adfaf" "adfaf" "adfaf"]
>["adfaf" "adfaf" "adfaf" "adfaf"]]
>
>How to simply write at any multidimensional array position? ar/:i/:j:
>value doesn't work ...
What happened in your example is that even though you used copy,
the same string was used to initialize every value in the array.
When you do CHANGE AR/1/1 you're changing that string, so the
change appears at every position in the array. You could do:
>> change ar/1 "adfaf"
== ["" "" ""]
>> ar
== [["adfaf" "" "" ""] ["" "" "" ""] ["" "" "" ""]]
Or you could do:
>> poke pick ar 1 1 "fafda"
== ["fafda" "" "" ""]
Or my favorite which is:
>> repoke ar [1 1] "fafda"
== ["fafda" "" "" ""]
>> source repoke
repoke: func [
"sets value within nested blocks"
block [block! hash! function! object!]
indexes [block!]
value [any-type!]
][
indexes: reduce indexes
while [1 < length? indexes] [
block: pick :block first indexes
indexes: next indexes
]
poke block first indexes value
]
Cheers,
Eric