[REBOL] Re: En Masse block operations
From: ingo:2b1 at: 16-Oct-2001 21:03
Hi Tim,
by now you've heard about map more than once, one other
possibility would be, e.g.
Once upon a time Tim Johnson spoketh thus:
> 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"]
== [[1 2 3 4] [5 6 7 8] [9 10 11 12] [13 14 15 16 17] "one"]
>> forall blk [if block? blk/1 [ blk/1: next blk/1 ]]
== []
>> blk: head blk
== [[2 3 4] [6 7 8] [10 11 12] [14 15 16 17] "one"]
>> forall blk [if block? blk/1 [ blk/1: head blk/1 ]] blk: head blk
== [[1 2 3 4] [5 6 7 8] [9 10 11 12] [13 14 15 16 17] "one"]
kind regards,
Ingo