Re: [Tutor] trying to understand pattern matching code

2014-04-26 Thread rahmad akbar
hi Alan, your explanation clears most things, super thanks!! On Sat, Apr 26, 2014 at 10:58 AM, Alan Gauld wrote: > On 26/04/14 09:36, rahmad akbar wrote: > >> but i still couldnt get this line though >> >> D = (( D << 1) + 1) & masks [ c ] > > > Do you understand the concept of bit shifting? >

Re: [Tutor] trying to understand pattern matching code

2014-04-26 Thread Alan Gauld
On 26/04/14 09:36, rahmad akbar wrote: but i still couldnt get this line though D = (( D << 1) + 1) & masks [ c ] Do you understand the concept of bit shifting? ie 000110 shifted left gives 001100 and 000110 shifted right gives 11 In other words the bit pattern moves left or right and

Re: [Tutor] trying to understand pattern matching code

2014-04-26 Thread rahmad akbar
Danny and Dave, super thanks on the plain text advice. i'm sending this mail on plain text, please let me know if it turned out to be otherwise back to the problem just googled binary and i now have some idea on it. i now understand turning on 16 and 8 gives 24 and thus 4+8 = 12. why is this? i no

Re: [Tutor] trying to understand pattern matching code

2014-04-25 Thread Dave Angel
rahmad akbar Wrote in message: > > to Dave, > i do i do the text mode? i had no idea this was on html Whatever mail program you're using is apparently defaulting to html. Find a menu item that specifies 'text' or 'plain text' or 'text only'. Or tell us what email program you're using, w

Re: [Tutor] trying to understand pattern matching code

2014-04-25 Thread rahmad akbar
Thanks joel Could you elaborate more on bitwise, and why do we need to double bit. I experimented with some input ShiftAnd('pattern', 'textcontainingpatternandpatern') print out the (masks, accept_state), looks like bellow, the rest make sense couse the numbers are doubled, but the 't' goes 4+8

Re: [Tutor] trying to understand pattern matching code

2014-04-25 Thread Dave Angel
You both posted in html, rather than text mode. Joel Goldstick Wrote in message: > > > > 1. what is line means? mask[c] |= bit > This bitwise or. It sets the rightmost bit in masks[c] Only the first time through the loop, when bit == 1 -- DaveA

Re: [Tutor] trying to understand pattern matching code

2014-04-25 Thread Joel Goldstick
On Apr 25, 2014 7:14 AM, "rahmad akbar" wrote: > > hey guys, > i am trying to understand this code pasted bellow, > 1. what is line means? mask[c] |= bit This bitwise or. It sets the rightmost bit in masks[c] > 2. then the line bit *=2, this increment the bit to 2 for each characters This doubles

[Tutor] trying to understand pattern matching code

2014-04-25 Thread rahmad akbar
hey guys, i am trying to understand this code pasted bellow, 1. what is line means? mask[c] |= bit 2. then the line bit *=2, this increment the bit to 2 for each character? 3. what is this line means? accept_state = bit //2 4. lastly, what is this scary line means? D = (( D << 1) + 1) & masks [ c d