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

[Mutability] Puzzle (*very hard*!)

 [1/9] from: lmecir::mbox::vol::cz at: 29-Sep-2006 15:41


are REBOL bitsets mutable or not? -Ladislav

 [2/9] from: greggirwin:mindspring at: 29-Sep-2006 8:11

Re: [Mutability bitset] Puzzle (*very hard*!)


Hi Ladislav, LM> are REBOL bitsets mutable or not? Two bitsets can refer to the same set of bits, and will return true for SAME?, but they aren't references to the same underlying bitset. However, you can use INSERT and REMOVE to modify a bitset, so they're mutable in that sense. -- Gregg

 [3/9] from: lmecir:mbox:vol:cz at: 29-Sep-2006 16:26


Gregg Irwin napsal(a):
> Hi Ladislav, > > LM> are REBOL bitsets mutable or not? > > Two bitsets can refer to the same set of bits, and will return true > for SAME?, but they aren't references to the same underlying bitset. >
they may or may not, that is the next part of the puzzle.
> However, you can use INSERT and REMOVE to modify a bitset, so they're > mutable in that sense. >
checking, whether INSERT mutates bitsets: bitset1: charset "" bitset1-2: :bitset1 insert bitset1-2 #"a" ; == make bitset! #{ 0000000000000000000000000200000000000000000000000000000000000000 } bitset1 ; == make bitset! #{ 0000000000000000000000000200000000000000000000000000000000000000 } , i.e. the bitset was indeed mutated, not just replaced! Congratulations, your answer was correct. So now the connected question: *Is there a way how to discern equal bitsets that don't reference identical underlying bitset?*

 [4/9] from: greggirwin:mindspring at: 29-Sep-2006 8:53


Hi Ladislav, LM> *Is there a way how to discern equal bitsets that don't reference LM> "identical" underlying bitset?* My first instinct would be to toggle a bit in one bitset, compare them, then toggle it back. -- Gregg

 [5/9] from: lmecir:mbox:vol:cz at: 29-Sep-2006 17:05


Gregg Irwin napsal(a):
> Hi Ladislav, > > LM> *Is there a way how to discern equal bitsets that don't reference > LM> "identical" underlying bitset?* > > My first instinct would be to toggle a bit in one bitset, compare > them, then toggle it back. > > -- Gregg >
yes, it was easy, as it looks. The only hard part may be, if the bitsets are a bit "nonstandard", like e.g. #[bitset! #{00}] -L

 [6/9] from: lmecir:mbox:vol:cz at: 29-Sep-2006 17:16


Ladislav Mecir napsal(a):
> Gregg Irwin napsal(a): >> Hi Ladislav,
<<quoted lines omitted: 13>>
> are a bit "nonstandard", like e.g. #[bitset! #{00}] > -L
hmm, this is strange, it looks to me, that INSERT works, while REMOVE actually doesn't? -L

 [7/9] from: greggirwin:mindspring at: 29-Sep-2006 9:40


Hi Ladislav,
>> LM> *Is there a way how to discern equal bitsets that don't reference >> LM> "identical" underlying bitset?* >> >> My first instinct would be to toggle a bit in one bitset, compare >> them, then toggle it back. >>
LM> yes, it was easy, as it looks. The only hard part may be, if the LM> bitsets are a bit "nonstandard", like e.g. #[bitset! #{00}] You should always be able to use an integer! value with FIND/INSERT/REMOVE, to toggle the low bit. You may also want to compare the bitset lengths, if that's important. -- Gregg

 [8/9] from: lmecir::mbox::vol::cz at: 29-Sep-2006 17:56


Gregg Irwin napsal(a):
> Hi Ladislav, >>> LM> *Is there a way how to discern equal bitsets that don't reference
<<quoted lines omitted: 8>>
> You should always be able to use an integer! value with > FIND/INSERT/REMOVE, to toggle the low bit.
Does REMOVE work for you? - it does not for me here :-(

 [9/9] from: greggirwin:mindspring at: 29-Sep-2006 10:11


Hi Ladislav, LM> Does REMOVE work for you? - it does not for me here :-( You have to use REMOVE/PART. -- Gregg

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