Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: [array] Some other questions

From: AJMartin:orcon at: 24-Dec-2003 22:49

Hi, Joel! Joel wrote:
> Given the available documentation for ARRAY: > ... > /initial -- Specify an initial value for all elements > it is consistent that the (single!) initial value is uses for all
elements. Hmmm, at the moment, I can't see a good use for an array that has multiple references to the one series or object. :-/ The /Initial refinement seems, to me, to indicate a initial value for each element, implying that each element in the result is distinct. I believe that 'array is more useful to most people when each value is a unique value, like:
>> x: array/initial 10 123
== [123 123 123 123 123 123 123 123 123 123]
>> x/1: x/1 + 456
== [579 123 123 123 123 123 123 123 123 123]
>> x: array/initial 10 "abc"
== ["abc" "abc" "abc" "abc" "abc" "abc" "abc" "abc" "abc" "abc"]
>> insert tail x/1 "def"
== ""
>> x
== ["abcdef" "abc" "abc" "abc" "abc" "abc" "abc" "abc" "abc" "abc"] And if I do need a block with multiple references to the one series or object, I can very easily write:
>> x: head insert/dup [] "abc" 10
== ["abc" "abc" "abc" "abc" "abc" "abc" "abc" "abc" "abc" "abc"]
>> insert tail x/1 "def"
== ""
>> x
== ["abcdef" "abcdef" "abcdef" "abcdef" "abcdef" "abcdef" "abcdef" "abcdef" abcdef "abcd ef"] Just my opinion. :) Andrew J Martin Speaking in tongues and performing miracles. ICQ: 26227169 http://www.rebol.it/Valley/ http://valley.orcon.net.nz/ http://Valley.150m.com/