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

Quickest way home using bitsets...

 [1/6] from: Rebolinth::nodep::dds::nl at: 14-Oct-2003 22:10


Hello All, After discovering the world of bitsets (they must have eaten Kellogs that morning at rebol ;-) I was wondering how crispy it could get? What im trying to accomplish is to reverse a bitset! Or better.. to extract to complete contence from a bitset! Bitsets are pritty hard on the mind and thow should not work on it all day :-) ..Still i was not able to lauch a trick to do a reverse bitset.. Assume this is the bitset: make bitset! #{ 00000000010000000000000032D19C0000000000000000000000000000000000 } How do i get back its contents? Shifting my way back through all 256 bits? I cant believe thats the only way to do it...uhum.. For those who dont know how bitsets work: a bitset is always a multiply of length? 8 (they all go by eight those little drawfs..) dwarf: make bitset! 8 will become #{00} To be able to insert some dwarfs in the bitset you can use 'insert like: insert dwarf 0 (that is, dwarf 0 is the smalest and 7 is the talest in a range of 8 dwarfs..) will result in #{01} insert dwarf 7 (after inserting a 1 into the dwarf..will become) #{81} etc...etc... can become even more fun when ending up doing upto lengths of 256 ;-) try the trick at home or in your mind "128 64 32 16 8 4 2 1" for length 8 Anyway im wandering again off the path, I know there are some real guru's here sniffing those bitsets for over more then 4 years now :-) In the land where myself is only a "urug" trying to find my way back through the bitsets and by bread is almost gone during roaming the forests. Who has help, i mean on the bitsets :-) Mmmm sounds like I eat too much kellogs ... (R)egards, Norman. -- Conversation/lunch: "How do you Eat your Rebol in the Morning?"

 [2/6] from: greggirwin:mindspring at: 14-Oct-2003 17:32


Hi Norman, R> What im trying to accomplish is to reverse a bitset! R> Or better.. to extract to complete contence from a bitset! I think Brett(?) had a module that did that, but I'm not sure where it is. I might have it here somewhere if nobody else knows. -- Gregg

 [3/6] from: brett:codeconscious at: 15-Oct-2003 10:15


Hi Norman and Gregg,
> R> What im trying to accomplish is to reverse a bitset!
Grab a silver backed piece of glass and hold it close to your monitor - voila! a bitset reversed! Series! are an ordered sequence of items. Conceptually, Bitset! does not record a sequence, it records set membership, but it does assign an index number to individual bits. So you cannot reverse a bitset like you can reverse a series. If you decide to imply that your bitset has a sequence using your own conventions, then to reverse the bitset you will have to convert it into a series, reverse that and convert that back to a bitset.
> R> Or better.. to extract to complete contence from a bitset! > > I think Brett(?) had a module that did that, but I'm not sure where it > is. I might have it here somewhere if nobody else knows.
I have an old script on my website but it uses the iteration method which Norman is trying to avoid. Norman, be warned, the following will encourage your "wandering again off the path":
>> enbase/base load at mold insert make bitset! 16 1 14 2
== "0000001000000000"
>> enbase/base load at mold insert make bitset! 16 2 14 2
== "0000010000000000"
>> enbase/base load at mold insert make bitset! 16 8 14 2
== "0000000000000001" Brett.

 [4/6] from: Rebolinth:nodep:dds:nl at: 15-Oct-2003 10:54


Hello Gregg and Brett, Thanks for the additional information on bitsets, again very informational! ;-) ..Ill continue breaking my head on the bitsets futher on... By the way, did one of you perhpas did any testing on the speed of using bitsets compared to the use of strings or blocks containing regualar data? (Speaking now of huge amount of data inside bitsets or blocks?) (R)egards, Norman. -- Conversation/lunch: "How do you Eat your Rebol in the Morning?"

 [5/6] from: rebol-list2:seznam:cz at: 23-Oct-2003 13:39


Hello Rebolinth, Tuesday, October 14, 2003, 10:10:42 PM, you wrote: R> Hello All, R> After discovering the world of bitsets (they must have eaten Kellogs that morning at rebol ;-) R> I was wondering how crispy it could get? R> What im trying to accomplish is to reverse a bitset! R> Or better.. to extract to complete contence from a bitset! R> Bitsets are pritty hard on the mind and thow should not work on it all day :-) R> ..Still i was not able to lauch a trick to do a reverse bitset.. R> Assume this is the bitset: R> make bitset! #{ R> 00000000010000000000000032D19C0000000000000000000000000000000000 R> } R> How do i get back its contents? Shifting my way back through all 256 bits? R> I cant believe thats the only way to do it...uhum.. R> For those who dont know how bitsets work: R> a bitset is always a multiply of length? 8 (they all go by eight those little drawfs..) R> dwarf: make bitset! 8 will become #{00} R> To be able to insert some dwarfs in the bitset you can use 'insert like: R> insert dwarf 0 (that is, dwarf 0 is the smalest and 7 is the talest in a range of 8 dwarfs..) R> will result in #{01} R> insert dwarf 7 (after inserting a 1 into the dwarf..will become) #{81} R> etc...etc...
>> dwarf: make bitset! 8
== make bitset! #{00} ;is something like: 2#{00000000}
>> insert dwarf 0
== make bitset! #{01} ;is something like: 2#{00000001} this seems to be a bug to me... send it to the feedback It looks that now there is used 0 for first bit. You can use only range 0 - 7 to set bits in this bitset it should be 1 - 8 to be more consistent, but who use it anyway? It's used only for parsing (charset is only shortcut for bitset) -- Best regards, rebOldes -----------------[ http://oldes.multimedia.cz/ ]

 [6/6] from: rotenca:telvia:it at: 23-Oct-2003 20:46


> it should be 1 - 8 to be more consistent, but who use it anyway? > It's used only for parsing (charset is only shortcut for bitset)
I use it for flags, and also RT use it in some code for the same. But the most important use, perhaps, is when you read a binary file, in the header often you find flags in bits and you can do: bin: #{01} bt: to bitset! bin find bt 0 0-7 for bit is consistent with all computer science ;-) --- Ciao Romano