On Tue, May 02, 2000 at 06:17:10PM +0300, Ariel Scolnicov wrote: > Bennett Todd <bet@rahul.net> writes: > > > Well, if you have > > > > print "$_ is a power of two\n" unless $_&$_-1; > > > > and you want to toggle the value if $_==0, how about > > > > print "$_ is a power of two\n" if !$_^!($_&$_-1); > > At the cost of making the code clearer, you could ignore the value > when $_ == 0, just say: > > print "$_ is a power of two\n" if $_&&($_&$_-1); > > and save another character. That's equivalent to the original 7-character code, and your logic is backwards. > > which comes to 14 if I count right. Sure is a shame that there isn't > > a ^^ operator, which like && and || would treat its args as booleans > > rather than bitstrings. They could have done that when they > > introduced xor, but as best I can tell they didn't. > > Short-circuit XOR operator? Is that like the "electricity powder" we'd > send people to get from the technical stores in the Army, so we could > fix flat batteries? Note that he never said 'short-circuit'. He said 'boolean'. C<and> and C<or> short-circuit, but C<xor> doesn't (of course). C<^^> could be the same. Ronald ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe