On 09/19/2011 11:20 PM, bearophile wrote:
A tiny puzzle I've shown on IRC. This is supposed to create an inverted array of cards, but what does it print instead?import std.stdio, std.algorithm, std.range; void main() { int[52] cards; copy(iota(cards.length - 1, -1, -1), cards[]); writeln(cards); } Bye, bearophile
The same as this code, of course!
import std.stdio, std.algorithm, std.range;
void main() {
int[52] cards;
for(auto i=cards.length-1,v=0; i>-1; i--, v++) cards[i]=v;
writeln(cards);
}
