new !-based secret operators

2007-11-30 Thread Dmitry Karasik
Good news everyone!

Excuse exclamation marks abound, but this message is all about a set of new
secret operators I thought of, all based on the exclamation sign. The boolean
negation is not really often used, but when is, the brevity of ! cannot be
overestimated.

Anyway, here's a set of conditional decrement/increment operators:

  $x +=!! $y  is same as $x++ if $y;
  $x -=!! $y   --$x-- if $y;
  $x +=!  $y   --$x++ unless $y;
  $x -=!  $y   --$x-- unless $y;

and for the completeness sake, 

  $x *=!! $y   --$x = 0 unless $y ,
  $x *=!  $y   --$x = 0 if $y;

This bunch, I think, can be appropriately named screwdriver operators:

   -=! and -=!!- flathead
   +=! and +=!!- phillips
   *=! and *=!!- torx

I don't know what name fits best to distinguish between ! and !! versions
though.

But that's not all. There's also a binary form for the increment and decrement:

   $x +!!+ $y  --$x + ( $y ? 1 : 0);
   $x -!!- $y  --$x - ( $y ? 1 : 0);
   $x +!+  $y  --$x + ( $y ? 0 : 1);
   $x -!-  $y  --$x - ( $y ? 0 : 1);
  
These actually are not completely useless. Consider the often-used calculation
of how many buckets are required for a number of items, with max items per
bucket.  The usual form is 

   $n = int( $items / $max) + (( $items % $max) ? 1 : 0);

whereas 
   
   $n = int( $items / $max) +!!+ $items % $max;

is both more short and elegant :) Again, I don't know how to name these four.

And finally, we come to the useless ones, which I found funny but unfortunately
completely impractical. Here's a not-or (NOR) boolean operator that only
reliably operates on 0s and 1s as arguments (actually on a bit more than that,
but it's not that interesting): 

   0 !~! 0 = 1
   0 !~! 1 = 0
   1 !~! 0 = 0
   1 !~! 1 = 0

This one I named the Tesla operator, because it somehow resembles two
electrodes with a spark between them. And finally, for the pure fun of it -
two boolean constants, 

!()-- true  
!%!-- false

These two deserve to be named the Mongolian constants, because !%!
really resembles that soyombo thingy on the mongolian national flag
( 
http://upload.wikimedia.org/wikipedia/commons/thumb/4/4c/Flag_of_Mongolia.svg/125px-Flag_of_Mongolia.svg.png
 ).
I was even tempted to say Mongolian Tao constants, because the thingy actually
contains the yin-yang sign, which can be also thought as a graphical 
representation of
a non-boolean, yet definitely binary logic :)

-- 
Sincerely,

Dmitry Karasik





Re: new !-based secret operators

2007-11-30 Thread Keith Ivey

Uri Guttman wrote:

you, sir, have altogether too much free time!! would you like to stop
wasting your life and help improve some cpan modules of mine? :)


Uri, what list do you think this is?  The phrase wasting your life is 
not allowed here, unless you can work it into a JAPH or something.


--
Keith C. Ivey [EMAIL PROTECTED]
Washington, DC


Re: new !-based secret operators

2007-11-30 Thread Georg Moritz
From the keyboard of Uri Guttman [30.11.07,13:02]:

  DK == Dmitry Karasik [EMAIL PROTECTED] writes:
 
   DK Hi Uri!
   Uri you, sir, have altogether too much free time!! would you like to stop
   Uri wasting your life and help improve some cpan modules of mine? :)
 
   DK will I get permission to pepper them with obfuscations and 
   DK secret operators to my heart's content? :)
 
 this is code for cpan. your requests are requirements for top quality
 cpan code!

To (mis)quote Fred Allen --

  CPAN is a medium because anything well done is rare.

:-P

0--gg-

-- 
_($_= x(15).?\n.q·/)Oo.  G°\/
  /\_¯/(q/
  \__(m.·.(_(always off the crowd)).·
);sub _{s,/,($e='Itrs `mnsgdq Gdbj O`qkdq)=~y/-y/#-z/;$e,e  print}

Re: The flaming X-wing secret operator

2007-11-30 Thread Yanick Champoux

shmem wrote:

in fact, shmem and Georg are the same guy, though 'Georg' just slipped ;-)


	One would think that the same sig and style and everything would have 
tipped me off.  But no... That was too suble for me still. :-P



Me likes. Lots.  I propose, as alternative names for those two tokens,
the fat bat (because it does look like a particularly rotund specimen of
that species, and in honor of the large value it yields) and thelaughing
joker (as in, just kidding, the rest of the line doesn't apply). :-)


Names OK. I'm glad you didn't come up with 'spacestation broken solar
panels' or such ;-D


	Oh, I considered it. But at the end, I thought that the other 
suggestions were rolling off the tongue a wee bit better. ;-)



Joy,
`/anick


Re: new !-based secret operators

2007-11-30 Thread Uri Guttman
 DK == Dmitry Karasik [EMAIL PROTECTED] writes:

  DK   Hi Uri!
  Uri you, sir, have altogether too much free time!! would you like to stop
  Uri wasting your life and help improve some cpan modules of mine? :)

  DK will I get permission to pepper them with obfuscations and 
  DK secret operators to my heart's content? :)

this is code for cpan. your requests are requirements for top quality
cpan code!

uri

-- 
Uri Guttman  --  [EMAIL PROTECTED]   http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs    http://jobs.perl.org


Re: The flaming X-wing secret operator

2007-11-30 Thread Philippe Bruhat (BooK)
On Fri, Nov 30, 2007 at 09:43:36AM +0100, Philippe Bruhat (BooK) wrote:
 
  Me likes. Lots.  I propose, as alternative names for those two tokens, 
  the 
  fat bat (because it does look like a particularly rotund specimen of that 
  species, and in honor of the large value it yields) and thelaughing joker 
  (as in, just kidding, the rest of the line doesn't apply). :-)
 
 Of course, we now need canonical usage examples of those two.
 

One usage could combine them two. When you need to use the largest
possible integer on 32 bits, you can use them both. Of course, it's a
slight golf (1 character winned), but a real golfer will do much better.

2**32-1  # UINT_MAX
[EMAIL PROTECTED]@^   # fat bat  laughing joker
~0   # golf hole

-- 
 Philippe Bruhat (BooK)

 The right answer is worthless with the wrong question!
(Moral from Groo The Wanderer #88 (Epic))


Re: The flaming X-wing secret operator

2007-11-30 Thread Philippe Bruhat (BooK)
On Thu, Nov 29, 2007 at 08:01:45PM -0500, Yanick Champoux wrote:
 shmem wrote:
 To brighten up your day - here's the winged moon, which isn't an
 operator, but a constant:

 [EMAIL PROTECTED]

 Georg added:
 Similar to the winged moon - an operator (token?) which scares
 the hell out of the remainder of a list:

 [EMAIL PROTECTED]


   Me likes. Lots.  I propose, as alternative names for those two tokens, 
 the 
 fat bat (because it does look like a particularly rotund specimen of that 
 species, and in honor of the large value it yields) and thelaughing joker 
 (as in, just kidding, the rest of the line doesn't apply). :-)

Of course, we now need canonical usage examples of those two.

-- 
 Philippe Bruhat (BooK)

 Blood is thicker than water... so beware of thick relatives.
(Moral from Groo The Wanderer #18 (Epic))


Re: new !-based secret operators

2007-11-30 Thread Dmitry Karasik
Hi Uri!


 Uri you, sir, have altogether too much free time!! would you like to stop
 Uri wasting your life and help improve some cpan modules of mine? :)

will I get permission to pepper them with obfuscations and 
secret operators to my heart's content? :)

-- 
Sincerely,
Dmitry Karasik