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

[REBOL] Re: Is unique buggy?

From: carl:cybercraft at: 13-Aug-2002 20:05

On 13-Aug-02, Gregg Irwin wrote:
> Hi Louis, > << Does unique not work with objects? >> > I think not.
Well, it sort of does. For instance this...
>> unique reduce [make object! [a: 10] make object! [a: 10]]
== [ make object! [ a: 10 ] make object! [ a: 10 ]] doesn't see those objects as unique, they not being the "same" objects, even if they're "equal" from our point of view. But when they are the same objects...
>> obj: make object! [a: 10] >> blk: reduce [obj obj]
== [ make object! [ a: 10 ] make object! [ a: 10 ]]
>> unique blk
== [ make object! [ a: 10 ]] unique can see they're the same. Either way, I'd say Louis's results are a bug, as it shouldn't be returning a corrupt block like that even if it can't tell if two objects are equal. If it's any help Louis, molding the objects in the block should allow you to extract the unique (as in equal) objects from it. Not a perfect solution, (for instance, the indexes of series wouldn't be preserved when you convert them back to an object, never mind the overhead in converting to a string then back to an object), but it might work for what you're doing. -- Carl Read