Comment On If ++ Increments ...

If yesterday's post was a bit too long for you, you may appreciate today's three-liner. It's from Steve Local, who had this conversation he had with one of his ... less gifted ... co-workers that was having some C# issues ... [expand full text]
« PrevPage 1 | Page 2 | Page 3 | Page 4 | Page 5 | Page 6Next »

Re: If ++ Increments ...

2005-05-10 13:52 • by diaphanein

Of course, the answer is:


i++++++++++++++++++++++;


[:P]

Re: If ++ Increments ...

2005-05-10 13:53 • by Stephan Rose

i+++++++++++;

Re: If ++ Increments ...

2005-05-10 13:54 • by diaphanein
34033 in reply to 34031
Anonymous:

Of course, the answer is:


i++++++++++++++++++++++;


[:P]



Although, I should have used prefix notation...

Re: If ++ Increments ...

2005-05-10 13:59 • by Jeff S
34034 in reply to 34033
duh ... all you need is a recursive function, XML, and javascript and you are off and running !

Re: If ++ Increments ...

2005-05-10 14:13 • by spacey
34039 in reply to 34034
ROFL

Re: If ++ Increments ...

2005-05-10 14:15 • by spotcatbug
More readable:



for (int j = 0; j < 11; j++)

    i++;



Re: If ++ Increments ...

2005-05-10 14:15 • by macman
WTF, of course you've got to use a loop, yes?  And, I'd do it in Java





int j=0;


for (int i=0; i<11; i++)


{


  j++;


}





or better yet





int j=0;


for (int i=0; i<11; i=i+1)


{


  j = j +1;


}





but personally, I'd use


int j;


.


.


.


j +=11;





but what do I know, I just been doing this stuff since Moses. - Mac

Re: If ++ Increments ...

2005-05-10 14:16 • by spotcatbug
34042 in reply to 34040
Ha, ha! That's not more readable at all. Somehow my post got garbbled.

Re: If ++ Increments ...

2005-05-10 14:17 • by Lenny
I know.  You need to put it in a while loop!



while (i  <  (i+11))

{

    i++;

}

Re: If ++ Increments ...

2005-05-10 14:18 • by cm5400
34044 in reply to 34034

Jeff S:
duh ... all you need is a recursive function, XML, and javascript and you are off and running !


How about assembly, it workes better than javascript!  Something to the effect of this, it has been awhile!


 


pusha


mov ax, i


mov bx, Bh


add ax, bx


mov i, ax


popa


 

Re: If ++ Increments ...

2005-05-10 14:19 • by rogthefrog
34045 in reply to 34043

You guys call yourselves programmers? The way to do this is


++i;


++i;


++i;


++i;


++i;


++i;


++i;


++i;


++i;


++i;


++i;

Re: If ++ Increments ...

2005-05-10 14:30 • by fooji
i beg to differ you should just overload the ++ operator



public static Complex operator ++(Complex c1)

{

      return new Complex(c1 += 11);

}

Re: If ++ Increments ...

2005-05-10 14:32 • by Bob
34048 in reply to 34045
How can you read that?!?!  It has to be all on one LINE!!!



++i;++i;++i;++i;++i;++i;++i;++i;++i;++i;++i;



Re: If ++ Increments ...

2005-05-10 14:32 • by mikey
34049 in reply to 34041
for (; i < 11 ; ++i );

Re: If ++ Increments ...

2005-05-10 14:35 • by Tallies

I can just see it now!


int toAdd = 5;
for(int i = 1; i<=11; i++)
   toAdd++;
   
Console.WriteLine(toAdd);


LMFAO! That was hilarious!

Re: If ++ Increments ...

2005-05-10 14:37 • by bugsisus
34051 in reply to 34048
Anonymous:
How can you read that?!?!  It has to be all on one LINE!!!



++i;++i;++i;++i;++i;++i;++i;++i;++i;++i;++i;






why not mix it up a little

++i;i++;++i;i++;++i;i++;++i;i++;++i;i++;++i;

Re: If ++ Increments ...

2005-05-10 14:42 • by andrew
c'mon...use OO, it's simpler:



private void button1_Click(object sender, System.EventArgs e)

        {

            Incrementer i = new Incrementer(0);

            i.OnTooFar += new Incrementer.TooFarHandler(number_OnTooFar);



            i = IncrementBy11(i);

           

            MessageBox.Show(i.Value.ToString());

        }



        private bool _isTooFar = false;



        public Incrementer IncrementBy11(Incrementer number)

        {

            while(!_isTooFar)

            {

                number.Value++;

            }

            return number;

        }



        public class Incrementer

        {

            private int _value;



            public Incrementer(int value)

            {

                _value = value;

            }



            public int Value

            {

                get {return _value;}

                set

                {

                    _value = value;

                    OnTooFar(new TooFarArgs(_value));

                }

            }



            public event TooFarHandler OnTooFar;



            public delegate void TooFarHandler(TooFarArgs args);



            public class TooFarArgs

            {

                public int HowMuch = 0;

       

                public TooFarArgs(int howMuch)

                {

                    HowMuch = howMuch;

                }

            }

        }



        private void number_OnTooFar(FP.Member.TestApp.SqlBuilder.Incrementer.TooFarArgs args)

        {

            _isTooFar = args.HowMuch > 10;

        }

Re: If ++ Increments ...

2005-05-10 14:44 • by Chris
34053 in reply to 34045

For such exotic applications of the increment operator you will actually have to do it a little something like this:


using System;


namespace W.T.F
{
   class ThisIsHowToDoIt
   {
      static void Main()
      {
         MyInt x = 31;
         x++;
         
         Console.WriteLine(" x = {0}", x);
      }
   }
   
   class MyInt
   {
      private int _value;
      
      private MyInt(int value)
      {
         this._value = value;
      }
      
      public static implicit operator int(MyInt a)
      {
         return a._value;
      }
      
      public static implicit operator MyInt(int a)
      {
         return new MyInt(a);
      }
      
      public static MyInt operator++(MyInt a)
      {
         return a += 11;
      }
   }
}


Of course, if Nathan wants to increment by twelve we have to come up with a completely different beast...

[8-|] [:P] 

Re: If ++ Increments ...

2005-05-10 14:45 • by Mike R
34054 in reply to 34043
Anonymous:
I know.  You need to put it in a while loop!



while (i  <  (i+11))

{

    i++;

}





Even without the forum software mangling the post this is my favorite.



FYI this is how it really reads:





while (i < (i+11))
{
i++;
}


(reposted from firefox, becuase the forum software is too stupid to
strip unnecessary HTML from the post when within a preformatted text
block, and too stupid to allow an IE user the pleasure of the HTML
button that the firefox version inexplicably has.)



Re: If ++ Increments ...

2005-05-10 14:49 • by endothermal
34056 in reply to 34041

Anonymous:
WTF, of course you've got to use a loop, yes?  And, I'd do it in Java

int j=0;
for (int i=0; i<11; i++)
{
  j++;
}

or better yet

int j=0;
for (int i=0; i<11; i=i+1)
{
  j = j +1;
}

but personally, I'd use
int j;
.
.
.
j +=11;

but what do I know, I just been doing this stuff since Moses. - Mac


 


too funny I like the loop, let the compiler unroll that baby! and self documenting too!

Re: If ++ Increments ...

2005-05-10 14:50 • by rick
34057 in reply to 34054
Um, won't i always be less than i + 11 if you keep incrementing it?

Re: If ++ Increments ...

2005-05-10 14:55 • by endothermal

I'd say you definitely need a function for that, something like


public int incrementBy11(ref int j)


{


for (int i=0; i<11; i++)


{


   j++;


}


return j;


}


 


in turn you simply [;)] use


 


int k=0;


.


.


incrementBy11(ref k);


nice!

Re: If ++ Increments ...

2005-05-10 14:55 • by lamecoder
Everyone's missing the point... this guy doesn't just want any plain old incrementer.  He wants one that goes to eleven!



Re: If ++ Increments ...

2005-05-10 14:56 • by Mike R
34060 in reply to 34057
Anonymous:
Um, won't i always be less than i + 11 if you keep incrementing it?




and that is why I like it [;)]



(steps away and starts grumbling something about forum software, again...)

Re: If ++ Increments ...

2005-05-10 14:59 • by deja
34061 in reply to 34057
while(i++<11) { }

Re: If ++ Increments ...

2005-05-10 15:00 • by Maurits
34062 in reply to 34060
He's probably looking for



i += 11;

Re: If ++ Increments ...

2005-05-10 15:02 • by andrew
34063 in reply to 34057
Oh, you want to do it again? No problem, just add a new event handler:





        private void
number_OnTooFarAgain(FP.Member.TestApp.SqlBuilder.Incrementer.TooFarArgs
args)


        {


            _isTooFar = args.HowMuch > 21;


        }

Re: If ++ Increments ...

2005-05-10 15:02 • by Lenny
34064 in reply to 34057
Anonymous:
Um, won't i always be less than i + 11 if you keep incrementing it?




You're right!  I know how to fix it.



int j = 0;

while (i < (i+11))

{

    i++;

    j++;

    if (j == 11)

    {

      break;

    }

}

Re: If ++ Increments ...

2005-05-10 15:05 • by Chris
34065 in reply to 34053
Anonymous:

         MyInt x = 31;
         x++;
         

         Console.WriteLine(" x = {0}", x);



I'll leave it as an exercise to the reader to implement MyInt.ToString()... [:$]

Re: If ++ Increments ...

2005-05-10 15:09 • by spotcatbug
34066 in reply to 34054
Mike R:




while (i < (i+11))
{
i++;
}






Winner! ROFLMAO

Re: If ++ Increments ...

2005-05-10 15:11 • by csm
34067 in reply to 34062
Aw, now you've gone ahead and ruined the surprise. :)

Re: If ++ Increments ...

2005-05-10 15:12 • by tekiegreg
34069 in reply to 34064
Ok, this one truly hurts my eyes above all else, gawd 2 integers to increment one around what is already a worthless loop.....heck why don't we put this in VB.NET, and declare them all as objects too :-p while we have unlimited memory to spare...

Re: If ++ Increments ...

2005-05-10 15:15 • by Miszou

template< class T >
class Adder
{
public:
 T Increment( T &nOp, T nSize )
 {
  if ( nSize == 0 )
   return nOp;
  if ( nSize > 0 )
   return Increment( ++nOp, nSize-1 );
  else
   return Increment( --nOp, nSize+1 );
 }
};


int main(int argc, char* argv[])
{
 int n = 0;
 Adder< int > *pAdder = new Adder< int >;
 pAdder->Increment( n, 11 );
 return n;
}


Re: If ++ Increments ...

2005-05-10 15:20 • by loneprogrammer
// increment by eleven

while(i != i + 11) {


   i++;


}




Re: If ++ Increments ...

2005-05-10 15:31 • by rogthefrog
34073 in reply to 34071

loneprogrammer:
// increment by eleven
while(i != i + 11) {
   i++;
}


Save trees! Use less space!


while(i++ < i + 11) {}


[6]

Re: If ++ Increments ...

2005-05-10 15:31 • by Mike R
Alex Papadimoulis:
If yesterday's post was a bit too long for you, you may appreciate today's three-liner. It's from Steve Local, who had this conversation he had with one of his ... less gifted ... co-workers that was having some C# issues ...

Nathan: Steve, you know how ++ will increment, right?
Steve: Right ....
Nathan: Okay, so how do you increment by 11?





At which point does Natan realise he's asked a stupid question? How can
people like this sleep at night calling themselves programmers?



These, and many more question on WWTF news at 9

Re: If ++ Increments ...

2005-05-10 15:39 • by Alex Papadimoulis
Hahahaha ... these are great!!

Re: If ++ Increments ...

2005-05-10 15:42 • by DerelictMan
34076 in reply to 34059
I was waiting for someone to make that joke. :)

Re: If ++ Increments ...

2005-05-10 15:43 • by craig
34077 in reply to 34071
I think a case statement will be the most efficient, unfortunately you can only increment positive numbers.



void add11(int* i) {



     if (*i > 11) {

      int j = *i -11;

      add11(&j);

      *i =  11 + j;

     }

     else {

      switch (*i) {

     

      case 0: *i = 11;

           break;



      case 1: *i = 12;

           break;



      case 2: *i = 13;

           break;



      case 3: *i = 14;

           break;



      case 4: *i = 15;

           break;



      case 5: *i = 16;

           break;



      case 6: *i = 17;

           break;



      case 7: *i = 18;

           break;



      case 8: *i = 19;

           break;



      case 9: *i = 20;

           break;



      case 10: *i = 21;

           break;



      case 11: *i = 22;

           break;
   

/* DON'T WANT THIS TO HAPPEN */

       default: exit();



      }

     }    

}



Re: If ++ Increments ...

2005-05-10 15:45 • by DerelictMan
34078 in reply to 34076
Anonymous:
I was waiting for someone to make that joke. :)




Damn it, I forgot this ain't Slashdot and this board doesn't thread the
messages for you, so I didn't quote.  Everyone ignore the idiot in
the corner...

Re: If ++ Increments ...

2005-05-10 15:46 • by Jake McArthur
34080 in reply to 34071
Many people here are making the same WTFs! Look at this one closely. i will never be equal to i+11!

Re: If ++ Increments ...

2005-05-10 15:48 • by Jake McArthur
34081 in reply to 34071
loneprogrammer:
// increment by eleven

while(i != i + 11) {


   i++;


}





Sorry, forgot to quote the one I was talking about.

Re: If ++ Increments ...

2005-05-10 15:49 • by Effendi
34082 in reply to 34059
So, is lamecoder the only one here besides me who got the Spinal Tap reference?

Re: If ++ Increments ...

2005-05-10 15:56 • by AJR
34083 in reply to 34057
Anonymous:
Um, won't i always be less than i + 11 if you keep incrementing it?


Not necessarily.  Eventaully, i will overflow (if I have too much
[B] :P) and then it will be significantly more that i+11 - to be exact,
if
it's a signed 32-bit int, i will be 2147483637 and i+11 will be
-2147483638.





Of course, there might be slightly easier, faster and clearer ways of
setting i to 2147483637, but that would hardly be in the spirit of this WTF, would it? :-)

Re: If ++ Increments ...

2005-05-10 15:58 • by bro1
I personally like this one:



i++; ++i; i++; ++i;

i++; ++i; i++; ++i;

i++; --i; i--;  i++;

i++; ++i; ++i;

Re: If ++ Increments ...

2005-05-10 15:59 • by Richard
++++++++++++i++++++++++++++;

Re: If ++ Increments ...

2005-05-10 16:00 • by AJR
34086 in reply to 34083
Damn you and your crazy posting interface, that "[B]" was meant to be the glass of beer from the smilies :-/

Re: If ++ Increments ...

2005-05-10 16:15 • by Jeff S
34087 in reply to 34086

Yes!  Good spinal Tap reference! 


I also love the "incrementor" class library, that will be really handy. 


Also, it's pretty funny how a few posts in this thread are people who don't get the joke(s)....

Re: If ++ Increments ...

2005-05-10 16:19 • by Pedant
34088 in reply to 34086
What amazes me is the number of people here who are posting code that
would just set i to 11, rather than to i + 11, or is that just another
deliberate wtf?

Re: If ++ Increments ...

2005-05-10 16:19 • by DZ-Jay
34089 in reply to 34085
Anonymous:
++++++++++++i++++++++++++++;




OMFG!!! stop it! you're killing me!! hahahahaha!

« PrevPage 1 | Page 2 | Page 3 | Page 4 | Page 5 | Page 6Next »

Add Comment