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

[REBOL] Re: reduce/deep

From: joel:neely:fedex at: 21-Oct-2003 15:39

Hi, Robert, Robert M. Münch wrote:
> Hi, ahhh forgot about this one. Rebol just has to many words to remember > ;-) But this doesn't seem to work for nested blocks: >
Sure it does!
>>>d: reduce [a b] >> > == [[a 1 b 2] [a 1 b 2]] > >>>e: reduce [a b] >> > == [[a 1 b 2] [a 1 b 2]] > >>>same? d e >> > == false >
Consider a simpler, analogous set of evaluations:
>> a: b: "xyz" == "xyz" >> same? a b == true >> c: reduce [a b] == ["xyz" "xyz"] >> d: reduce [a b] == ["xyz" "xyz"] >> same? c/1 d/1 == true >> same? c/2 d/2 == true >> same? c d == false >> equal? c d == true
or even *more* simpler (pardon the grammar! ;-)
>> p: "12" == "12" >> q: "12" == "12" >> same? p/1 q/1 == true >> same? p/2 q/2 == true >> same? p q == false >> equal? p q == true
These all illustrate the difference between SAME? and EQUAL? in that it is entirely possible to have two different series values whose corresponding elements are the same. In my first example above, as in your original post, two different REDUCE expressions over two different blocks will not produce THE SAME block, even if the content of those two blocks are the same. However the blocks are equal. My second example breaks it down even further. Two different appearances in the input of "12" correspond to two different strings, even though the corresponding characters in those strings are equal (and same, being immutable). Likewise, two different appearances of [a b] result in the creation of two different blocks, even though the corresponding words in those blocks are the same. Therefore, when we reduce those distinct but equal blocks, we get distinct but equal resulting blocks. -jn- -- ---------------------------------------------------------------------- Joel Neely joelDOTneelyATfedexDOTcom 901-263-4446 Enron Accountingg in a Nutshell: 1c=$0.01=($0.10)**2=(10c)**2=100c=$1