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

[REBOL] Re: compose: what do not understand?

From: joel::neely::fedex::com at: 3-Oct-2001 10:36

Hi, Romano, Romano Paolo Tenca wrote:
> Someone can explain to me where these two command differs? > Aren't the same thing? > > >> x: [] > == [] > >> compose [(:x)] > == [] > >> reduce [:x] > == [[]] >
Pardon me if I answer with too much detail... The essential difference in REDUCE and COMPOSE is that you get to decide what gets evaluated:
>> fee: "eenie" == "eenie" >> fie: "meenie" == "meenie" >> foe: "mynie" == "mynie" >> fum: "moe" == "moe" >> reduce [fee fie foe fum]
== ["eenie" "meenie" "mynie" "moe"]
>> compose [fee (fie) foe (head reverse copy fum)]
== [fee "meenie" foe "eom"] In addition, COMPOSE flattens its content, in the following way:
>> p: [1 2 3] == [1 2 3] >> q: [4 5 6] == [4 5 6] >> r: [7 8 9] == [7 8 9] >> reduce [p q r] == [[1 2 3] [4 5 6] [7 8 9]] >> compose [(p) (q) (r)] == [1 2 3 4 5 6 7 8 9]
and also eliminates empty blocks, as follows:
>> s: [] == [] >> reduce [p q s r] == [[1 2 3] [4 5 6] [] [7 8 9]] >> compose [(p) (q) (s) (r)] == [1 2 3 4 5 6 7 8 9]
HTH! -jn- -- This sentence contradicts itself -- no actually it doesn't. -- Doug Hofstadter joel<dot>neely<at>fedex<dot>com