Dont use 'foreach.  'Foreach makes a copy of the value, bungling your method.  Use
'forall or 'repeat.  I like using 'repeat for this sort of thing because I can do it
without the awkward [block: head block] at the end.

Also you might want to use 'block? instead of 'series? to validate whether an
operation is warranted.  Many other data values are considered a series...

>> series? "abc"
== true
>> series? ftp://bob.jones.com
== true
>> series? [EMAIL PROTECTED]
== true
>>

--Ryan

Tim Johnson wrote:

> Hello All:
>         I would like to apply the same operation to all members of a nested block.
> ;Example:
> blk: [[1 2 3 4] [5 6 7 8] [9 10 11 12] [13 14 15 16 17] "one"]
> blk: do-all blk next ; set all members to next element
> ;result sought:
> >>[[2 3 4] [6 7 8] [10 11 12] [14 15 16 17] "ne"]
> blk: do-all blk head ; set all members to head
> ; result sought:
> >>[[1 2 3 4] [5 6 7 8] [9 10 11 12] [13 14 15 16 17] "one"]
> ; I've started by this simple function, which is not doing just
> ; what I want:
> REBOL[]
> do-all: func[blk[block!] ][ ;cmd[word!]
>         foreach member blk[
>                 if series? member[
>                         member: next member
>                         print mold member
>                         ]
>                 ]
>         blk
>         ]
> test: [[1 2 3 4] [5 6 7 8] [9 10 11 12] [13 14 15 16 17] "one"]
> print mold do-all test
> ;and I get
> >> do %sample.r
> Script: "Untitled" (none)
> [2 3 4]
> [6 7 8]
> [10 11 12]
> [14 15 16 17]
> "ne"
> [[1 2 3 4] [5 6 7 8] [9 10 11 12] [13 14 15 16 17] "one"]
>
> TIA
> --
> Tim Johnson <[EMAIL PROTECTED]>
>        http://www.johnsons-web.com
> --
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the
> subject, without the quotes.

--


     Ryan Cole
 Programmer Analyst
 www.iesco-dms.com
    707-468-5400


-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to