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

compose: what do not understand?

 [1/4] from: rotenca:telvia:it at: 3-Oct-2001 14:59


Someone can explain to me where these two command differs? Aren't the same thing?
>> x: []
== []
>> compose [(:x)]
== []
>> reduce [:x]
== [[]] --- Ciao Romano

 [2/4] 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?
<<quoted lines omitted: 4>>
> >> 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

 [3/4] from: rotenca:telvia:it at: 3-Oct-2001 18:33


Hi, Joel
> In addition, COMPOSE flattens its content, in the following way:
Ah! Now all is clear! Thank you very much.
> -jn-
ciao romano

 [4/4] from: greggirwin:starband at: 3-Oct-2001 12:03


Good info Joel! In addition, Jeff (who wrote compose) has a great article about it in one of the old 'zine issues on REBOL Forces. Very informative. --Gregg

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted