[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Golf (7, er 16 strokes is par!)



On May 2, Bennett Todd said:

>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.

Camel, ed. 2, pg. 94:

  There is also a logical B<xor> operator that has no exact counterpart in
  C or Perl, since the other XOR operator (^) works on bits.  The best
  equivalent for C<$a xor $b> is perhaps C<!$a != !$b>[1].  This operator
  can't short-circuit either, since both sides must be evaluated.

  [1] One could write C<!$a ^ !$b> or even C<$a ? !$b : !!$b>, of course.

-- 
MIDN 4/C PINYAN, NROTCURPI, US Naval Reserve             japhy@pobox.com
http://www.pobox.com/~japhy/                  http://pinyaj.stu.rpi.edu/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe