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

[REBOL] Multiple ("block") SET operation on objects - revisited

From: geza67::freestart::hu at: 3-Oct-2001 18:25

Hello REBOLers, Back to the topic multiple set on objects: Here are my two variations on the subject. The 1st solution (SETP) works on block of objects in path notation only, the second one accepts both single words and objects inside its first argument block (SETX). setp: function [{Set multiple values at a time on block of objects (in path notation)} where-list [any-block!] value-list [any-block!]][lhead ltail i][ i: 0 foreach elem where-list [ i: i + 1 if (type? :elem) = path![ ltail: last lhead: to-block :elem lhead: head remove back tail lhead do compose [set/any in (to-path lhead) (to-lit-word ltail)(pick value-list i)] ] ] ] setx: function [{Set multiple values at a time on block of objects (in standard path notation) or words} where-list [any-block!] value-list [any-block!]][lhead ltail i][ i: 0 foreach elem where-list [ i: i + 1 do compose [set/any (switch type?/word :elem [ path! [ ltail: last lhead: to-block :elem lhead: head remove back tail lhead compose [in (to-path lhead)] ] word! [ ltail: :elem [] ] ]) (to-lit-word ltail)(pick value-list i)] ] ] -- Best regards, Geza Lakner MD mailto:[geza67--freestart--hu]