• diaphanein (unregistered)

    Of course, the answer is:

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

    [:P]

  • Stephan Rose (unregistered)

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

  • diaphanein (unregistered) in reply to diaphanein
    Anonymous:

    Of course, the answer is:

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

    [:P]

    Although, I should have used prefix notation...

  • (cs) in reply to diaphanein

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

  • spacey (unregistered) in reply to Jeff S

    ROFL

  • spotcatbug (unregistered)

    More readable:

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

  • macman (unregistered)

    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

  • spotcatbug (unregistered) in reply to spotcatbug

    Ha, ha! That's not more readable at all. Somehow my post got garbbled.

  • Lenny (unregistered)

    I know.  You need to put it in a while loop!

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

  • (cs) in reply to Jeff S

    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

     

  • (cs) in reply to Lenny

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

    <FONT color=#000080>++i;</FONT>

    <FONT color=#000080>++i;</FONT>

    <FONT color=#000080>++i;</FONT>

    <FONT color=#000080>++i;</FONT>

    <FONT color=#000080>++i;</FONT>

    <FONT color=#000080>++i;</FONT>

    <FONT color=#000080>++i;</FONT>

    <FONT color=#000080>++i;</FONT>

    <FONT color=#000080>++i;</FONT>

    <FONT color=#000080>++i;</FONT>

    <FONT color=#000080>++i;</FONT>

  • fooji (unregistered)

    i beg to differ you should just overload the ++ operator

    public static Complex operator ++(Complex c1)
    {
          return new Complex(c1 += 11);
    }

  • Bob (unregistered) in reply to rogthefrog

    How can you read that?!?!  It has to be all on one LINE!!!

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

  • mikey (unregistered) in reply to macman

    for (; i < 11 ; ++i );

  • (cs)

    I can just see it now!

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

    LMFAO! That was hilarious!

  • bugsisus (unregistered) in reply to Bob
    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;
  • andrew (unregistered)

    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;
            }

  • Chris (unregistered) in reply to rogthefrog

    <FONT face=Arial size=2>For such exotic applications of the increment operator you will actually have to do it a little something like this:</FONT>

    <FONT face="Courier New" size=2>using System;</FONT>

    <FONT face="Courier New" size=2>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;
          }
       }
    }</FONT>

    <FONT face=Arial size=2>Of course, if Nathan wants to increment by twelve we have to come up with a completely different beast...</FONT>

    <FONT face=Arial>[8-|] [:P] </FONT>
  • (cs) in reply to Lenny
    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.)

  • endothermal (unregistered) in reply to macman

    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!

  • rick (unregistered) in reply to Mike R

    Um, won't i always be less than i + 11 if you keep incrementing it?

  • endothermal (unregistered)

    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!

  • lamecoder (unregistered)

    Everyone's missing the point... this guy doesn't just want any plain old incrementer.  He wants one that goes to eleven!

  • (cs) in reply to rick
    Anonymous:
    Um, won't i always be less than i + 11 if you keep incrementing it?


    and that is why I like it [;)]

    <font size="1">(steps away and starts grumbling something about forum software, again...)</font>
  • deja (unregistered) in reply to rick

    while(i++<11) { }

  • (cs) in reply to Mike R

    He's probably looking for

    i += 11;

  • andrew (unregistered) in reply to rick

    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;

            }

  • Lenny (unregistered) in reply to rick
    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;
        }
    }
  • Chris (unregistered) in reply to Chris
    Anonymous:

    <FONT face="Courier New" size=2>         MyInt x = 31;
             x++;
             </FONT><FONT face="Courier New" size=2>
             Console.WriteLine(" x = {0}", x);</FONT>

    I'll leave it as an exercise to the reader to implement <FONT face="Courier New" size=2>MyInt.ToString()</FONT>... [:$]

  • spotcatbug (unregistered) in reply to Mike R
    Mike R:


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



    Winner! ROFLMAO
  • csm (unregistered) in reply to Maurits

    Aw, now you've gone ahead and ruined the surprise. :)

  • tekiegreg (unregistered) in reply to Lenny

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

  • (cs)

    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;
    }

  • (cs)

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

  • (cs) in reply to loneprogrammer

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

    Save trees! Use less space!

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

    [6]

  • (cs)
    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
  • (cs)

    Hahahaha ... these are great!!

  • DerelictMan (unregistered) in reply to lamecoder

    I was waiting for someone to make that joke. :)

  • craig (unregistered) in reply to loneprogrammer

    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();

          }
         }    
    }

  • DerelictMan (unregistered) in reply to DerelictMan
    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...
  • Jake McArthur (unregistered) in reply to loneprogrammer

    Many people here are making the same WTFs! Look at this one closely. i will never be equal to i+11!

  • Jake McArthur (unregistered) in reply to loneprogrammer
    loneprogrammer:
    // increment by eleven
    while(i != i + 11) {
       i++;
    }

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

  • Effendi (unregistered) in reply to lamecoder

    So, is lamecoder the only one here besides me who got the Spinal Tap reference?

  • AJR (unregistered) in reply to rick
    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? :-)

  • bro1 (unregistered)

    I personally like this one:

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

  • Richard (unregistered)

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

  • AJR (unregistered) in reply to AJR

    Damn you and your crazy posting interface, that "[B]" was meant to be the glass of beer from the smilies :-/

  • (cs) in reply to AJR

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

  • Pedant (unregistered) in reply to AJR

    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?

  • (cs) in reply to Richard
    Anonymous:
    ++++++++++++i++++++++++++++;


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

Leave a comment on “If ++ Increments ...”

Log In or post as a guest

Replying to comment #:

« Return to Article