Hi Rebolinth, I am not sure about what you are trying to achieve, but I think you may have the wrong idea about bitsets. Here are some examples to help you.
Bitsets are not series: >> series? make bitset! 8 == false However they do have a length - the number of bits (always a multiple of 8): >> length? make bitset! 8 == 8 >> length? make bitset! 16 == 16 The Charset function just creates bitsets from the character you specify: >> source charset charset: func [ "Makes a bitset of chars for the parse function." chars [string! block!] ][ make bitset! chars ] The number of bits in a bitset created by the Charset function is (currently) 256 - one bit to represent each possible character: >> length? charset "" == 256 With bitsets you are *only* turning some bits on and some bits off by a position number. Characters are translated to a position. > Is there a way to 'pick on bitsets? You use Find to test if a bit corresponding to your value is set: >> find charset "ab" "a" == true >> find charset "ab" "b" == true >> find charset "ab" "c" == none You can use the ascii value: >> find charset "*" 42 == true You can set bits corresponding to your value with Insert: >> find insert charset "ab" "d" "d" == true To enumerate all the characters represented in a bitset created using charset use a loop (notice also that the bitset does not record duplicates): bitset: charset "aaaaybcx" chars: copy {} for i 0 (subtract length? bitset 1) 1 [ if find bitset i [append chars to-char i] ] ?? chars When using Parse bitsets can be used for matching against a set of characters: my-chars: charset "xyz" is simpler and probably more efficient than my-chars: [#"x" | #"y" | #"z"] You can use bitsets with Find too: >> find "123x5" charset "xyz" == "x5" Clear, Empty?, Union, Interset, Exclude, Difference, Negate and Complement can be used on bitsets Example using just a small bitset. >> find insert make bitset! 8 6 6 == true Outside the range: >> insert make bitset! 8 9 ** Script Error: Invalid argument: 9 ** Near: insert make bitset! 8 9 >> find make bitset! 8 9 ** Script Error: Invalid argument: 9 ** Near: find make bitset! 8 9 Cheers, Brett. > > > Hallo All, > > Is there a way to 'pick on bitsets? > > Im looking for a way to select a range or a single character from a bitset on a specific location, > but i can emagine that the 'bitset does not do serie handing the way series does. > > I thought bitsets where smaler (and quicker using parsing) , but i can emagine using > a normal string range would even do the trick as quick as well? (which im currently using in my program) > > A simple example to visualise the problem.. > > ;;; example 1 > > t1: charset [ #"a" - #"q" #"x" - #"z" ] > t2: charset [ #"A" - #"Q" #"t" - #"v" ] > > pick t2 index? find t1 #"x" > > ;;; example 2 > > t1: charset "KHEWWKJEWBLKUWEOFBIYTEWQFBOYTEWUEQIUFBITWQUFB" > t2: charset "QWEIRLUYQWIURYLQWUYREOIWQUYROIQUWYEOIRUYWQEOI" > > pick t2 index? find t1 #"x" > > > The above does not work ... But is there a way to compare 2 bitsets ranges > with eachother, using parse perhpas?, like the above, but without ..union..etc...? > > > Regards, > Norman. -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject.