News for hackers. Stuff that matters.
Re:Why I absolutely love java by vilya on Tuesday February 08, 2011 @09:06PM (#2195925)
Here's a C++ 0x version, using a lambda function:

  #include <iostream>
  #include <algorithm>

  int main(int argc, char** argv) {
    int src[] = { 1, 2, 3, 4 };
    int* end = std::remove_if(src, src + sizeof(src) / sizeof(int),
        [](int i) -> bool { return i % 2 != 0; });
    for (int* p = src; p != end; ++p)
      std::cout << *p << " ";
    std::cout << std::endl;
  }
I wasn't sure about the lambda function syntax, but this compiles with g++ 4.5 (interestingly, even with the -Wall option, g++ doesn't warn about main not returning a value). Shows that even c++ can be shorter than java...
Re:Why I absolutely love java by serichsen on Wednesday February 09, 2011 @10:37AM (#2197725)
TL;DR