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

[REBOL] 'Foreach questions

From: tim::johnsons-web::com at: 21-Dec-2002 11:29

Fellow Rebols: I'm trying to use the same block of words in both a query and in parsing data from the query. To illustrate here's some test data, some results and some results I'm looking for... ; need some words set to literal values
>> col-names: set [a b c d] ["one" "two" "three" "four"]
== ["one" "two" "three" "four"] ; now some test data. Let's pretend that this data is retrieved ; by a query using col-names above
>> data: [[1 2 3 4] [5 6 7 8] [9 10 11 12]]
== [[1 2 3 4] [5 6 7 8] [9 10 11 12]] ; now I want to fetch each inner block in 'data and ; automagically set each word in 'col-names to each successive ; item in the inner block
>> foreach row data[set 'col-names row
prin mold col-names prin mold a prin mold b prin mold c print mold d ] [1 2 3 4]"one""two""three""four" [5 6 7 8]"one""two""three""four" [9 10 11 12]"one""two""three""four" ; alas, I've failed to get what I wanted. What I wanted to see is: [1 2 3 4] 1 2 3 4 [5 6 7 8] 5 6 7 8 [9 10 11 12] 9 10 11 12 ; where each 'word originally in col-names would be set to ; a return value Any ideas on how I can make this work for me in a similar fashion. TIA -- Tim Johnson <[tim--johnsons-web--com]> http://www.alaska-internet-solutions.com http://www.johnsons-web.com