[REBOL] Re: nforeach
From: g:santilli:tiscalinet:it at: 23-Jul-2003 10:23
Hi Andrew,
On Wednesday, July 23, 2003, 8:57:53 AM, you wrote:
AJM> I think I might like it better like this:
>>> nforeach [a b] [[1 2 3] [4 5 6]] [print [a b]]
Ironicly, that way you'd need NFOREACH inside NFOREACH... ;-) (Of
course, if you only support the case of one word per series, it
gets simple enough. But see below, if you want to use it on
tables.)
AJM> Table_Header: [a b]
AJM> Table_Rows: [
AJM> [1 4]
AJM> [2 5]
AJM> [3 6]
AJM> ]
>>> transpose Table_Rows
AJM> == [[1 2 3] [4 5 6]]
AJM> nforeach Table_Header transpose Table_Data [print [a b]]
Hmm, I would do this as:
foreach-row: func [table-header table-rows body] [
table-header: use table-header reduce [table-header]
bind body table-header/1 ; you might want to use bind/copy
; and check for an empty table-header
foreach row table-rows [
set table-header row
do body
]
]
(untested)
Regards,
Gabriele.
--
Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer
Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/