Re:Printing 1 to 1000 without loop or conditionals
by tptacek on Monday January 03, 2011 @03:41AM
(#2062604)
Where's the loop in the array initialization? Where's the loop in "map"? That's why one's clever and the other's a cheat.
[ Parent
| on HN ]
Re:Printing 1 to 1000 without loop or conditionals
by Raphael_Amiard on Monday January 03, 2011 @06:33AM
(#2062845)
The loop in the array initialization is generated by the compiler for the static version, by the runtime for the dynamic allocation version. It's still a loop.
You're just re-using a loop already implemented in the runtime. That's quite the same thing as using map, though a tiny bit clever. But if you qualify map as cheat, well then the constructor trick is just a cleverer cheat.