1. puzzling code
- Posted by joshua goldberg <futures8 at bellsouth.net> Aug 22, 2001
- 386 views
Hi, All. While studying Matt Arriola's Crypt.ex code (Recent User Contibutions), I found a line of code which I'm at a loss to understand. Simulated code follows; -- begin code with trace sequence bits object dummy trace(1) bits = "11000111001111000011100110101011" bits -= '0' <--- what's this doing??? dummy = 21 -- has no meaning ... here just for the trace -- end code if you run the above which trace on, and watch the display of variables under the trace window, you'll see how the line "bits -= '0' transforms the sequence bits. Can somebody explain what's happening ? Appreciate any help.
2. Re: puzzling code
- Posted by Chris Bensler <bensler at telus.net> Aug 22, 2001
- 384 views
> Hi, All. > > While studying Matt Arriola's Crypt.ex code (Recent User Contibutions), > I found a line of code which I'm at a loss to understand. > Simulated code follows; > > -- begin code > > with trace > sequence bits > object dummy > trace(1) > > bits = "11000111001111000011100110101011" > > bits -= '0' <--- what's this doing??? > > dummy = 21 -- has no meaning ... here just for the trace > -- end code > > if you run the above which trace on, and watch the display of > variables under the trace window, you'll see how the line > "bits -= '0' transforms the sequence bits. Can somebody explain > what's happening ? > > Appreciate any help. it's subtracting the the value of '0'(48) from the `bits` sequence, making each element the actual numeric value of number that is represented. In short, it's a quick and crude form of value() Chris
3. Re: puzzling code
- Posted by Chris Bensler <bensler at telus.net> Aug 22, 2001
- 373 views
I think joshua added the dummy variable so the value of bits would be displayed before the trace facily terminated. is there a reason why you didn't just write.. bits = {1,1,1,0,0,0,0,0,1,1,1,0,etc} or was that just from joshua's demo code? Chris > thanks for showing an interest in my code! ;) i believe chris explained > the thing with the binary code, but i forgot what that dummy object was > for...probably just a relic. in fact, i don't remember even putting it > in there! > > joshua goldberg wrote: > > Hi, All. > > > > While studying Matt Arriola's Crypt.ex code (Recent User Contibutions), > > I found a line of code which I'm at a loss to understand. > > Simulated code follows; > > > > *snip* > > > > > >