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

[REBOL] Re: REBOL Cookbook in Beta

From: g:santilli:tiscalinet:it at: 3-Sep-2003 10:16

Hi Michael, On Wednesday, September 3, 2003, 12:06:16 AM, you wrote: MJM> trying to accomplish. I.e., sort of the difference MJM> between the following ideas MJM> a < data | b | c | d | e | f > outfile MJM> and MJM> write f(e(d(c(b(a(data)))))) MJM> I prefer the first for clarity, given my experiences MJM> with the pipe idea. That's just syntactic sugar; indeed, you can easily make a "pipe" dialect in REBOL:
>> element: [copy el [word! [to '| | to end]] (push el)]
== [copy el [word! [to '| | to end]] (push el)]
>> pipe-expr: [element any ['| element]]
== [element any ['| element]]
>> result: []
== []
>> push: func [element] [result: compose [(element/1) (result) (next element)]] >> parse [data | a | b | c | d | e | f] pipe-expr
== true
>> result
== [f e d c b a data] This allows you to do thing like:
>> clear result
== []
>> parse [copy "REBOL" | append " powerful" | insert "Isn't " | append "? ;-)"] pipe-expr
== true
>> result
== [append insert append copy "REBOL" " powerful" "Isn't " "? ;-)"]
>> do result
== "Isn't REBOL powerful? ;-)" The above is just very QAD, but it could be easily made useful... Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/