Hi Gisle

Nice solution.  I would like to add a small clarification.  When you use
insert/dup it places 5 references to the one instance of the series into the
new block.

>> a: head insert/dup copy [] "series" 5
== ["series" "series" "series" "series" "series"]

>> a/2/1: #"a"    ;change first character of second series in block
== "aeries"

>> a
== ["aeries" "aeries" "aeries" "aeries" "aeries"]     ;They are all changed!

BTW adding copy before "series" will not change the behavior because
insert/dup only evaluates it once.

If we want independent copies of the series in the new block, we need to use
a different approach.

>> b: copy [] loop 5 [append b copy "series"]
== ["series" "series" "series" "series" "series"]

>> b/2/1: #"a"
== "aeries"

>> b
== ["series" "aeries" "series" "series" "series"]    ;only second series
changed

Now they are independent.

Which one you want depends on what you want to do with the block.

Cheers
-Larry

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 18, 2000 7:52 AM
Subject: [REBOL] shortcut? Re:


>
>
> You mean like this?:
>
> >> a: head insert/dup copy [] "series" 5
> == ["series" "series" "series" "series" "series"]
>
> Type 'help insert' to get more info.
>
> Cheers,
> Gisle
>
-------snip---------

Reply via email to