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

[REBOL] [tuple interpolation] Tuple interpolation (was: variables in pen color)

From: gregg:pointillistic at: 7-Aug-2010 13:24

Hi Petri, PK> Is there any way i can use variables in pen command? PK> pen (r.g.b) PK> There is no to-color function? What a great question! You found a solution, and Tom gave you another, but it prompted me to think about interpolation a bit. It's come up a few times over the years, but I haven't seen it in the context of tuples. tup: func [ ; tupify? ;) 'tuple [word!] /local words ][ words: parse form tuple "." forall words [change/only words to word! first words] to tuple! reduce words ] r: 0 g: 128 b: 255 print tup r.g.b set [a b c d e f g h i j] [1 2 3 4 5 6 7 8 9 10] print tup a.b.c.d.e.f.g.h.i.j Quick and dirty to be sure, but it might also be handy. Questions: What would be a good name for this? Should it just error out if you give it an invalid argument? That is a word in the tuple that refers to a non-integer value. -- Gregg