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

[REBOL] En Masse block operations

From: tim:johnsons-web at: 16-Oct-2001 9:25

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 <[tim--johnsons-web--com]> http://www.johnsons-web.com