Created
July 20, 2012 16:37
-
-
Save Idorobots/3151731 to your computer and use it in GitHub Desktop.
Common Lisp LOOP in D programming language - generated code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto random = (() { | |
auto max = 500; | |
auto __i_0 = max; | |
auto i = 0; | |
typeof(uniform(0, max))[] __accumulator; | |
for(;;) { | |
if(i >= __i_0) break; | |
__accumulator ~= uniform(0, max); | |
i += 1; | |
} | |
return __accumulator; | |
})(); | |
{ | |
auto __i_0 = 0; | |
auto __i_1 = random; | |
auto __i_2 = __i_1.length; | |
typeof(__i_1.init[0]) i; | |
uint evens = 0; | |
uint odds = 0; | |
typeof(i) total; | |
bool __max_3 = false; | |
typeof(i) max; | |
bool __min_4 = false; | |
typeof(i) min; | |
for(;;) { | |
if(__i_0 >= __i_2) break; | |
i = __i_1[__i_0]; | |
if((i&1) == 0) ++evens; | |
if((i&1) == 1) ++odds; | |
total += i; | |
if(!__max_3 || i > max) { | |
max = i; | |
__max_3 = true; | |
} | |
if(!__min_4 || i < min) { | |
min = i; | |
__min_4 = true; | |
} | |
++__i_0; | |
} | |
writeln("Stats: ", [min, max, total, evens, odds]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment