Fun.

Unsustainable work levels are fun.

http://www.artima.com/cppsource/cpp0x.html

Look at the beautiful simplicity of the new C++….

template using Vec = vector>;
Vec v = { 2.3, 1.2, 6.7, 4.5  };
sort(v);
for(auto p = v.begin(); p!=v.end(); ++p)
cout < < *p << endl;

Wow.

Its almost readable, no? Everyone can see what its saying. Its like reading english! Blegh.

Let’s try that same thing in ruby and try and guess what it does.

hash = [ 2.3, 5.3, 5.4, 6.3 ]
hash.sort!
hash.each do |item|
print item
end

I bet even adam could figure out what that does. And, since I can’t resist…

[2.3, 5.3, 6.4, 5.3].sort.each { |x| print x }

Not as easy to read, but to the point!

3 Responses to “Fun.”

  1. Adam Says:

    does it enable you to fly. or print money.

    that’s totally what it should do.

  2. Kelly Says:

    It initializes hash to random decimal values, calls sort function on hash, and the program prints each decimal value to a console window.

    Obviously.

  3. Hampton Says:

    Good one kelly!

Leave a Reply