Created
July 20, 2012 16:33
-
-
Save Idorobots/3151713 to your computer and use it in GitHub Desktop.
Common Lisp LOOP in the D programming language
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 = mixin(Loope!q{ | |
with max = 500 | |
for i from 0 to max | |
collect $$ uniform(0, max) $$ | |
}); | |
mixin(Loop!q{ | |
for i in random | |
counting $$ (i&1) == 0 $$ into evens | |
counting $$ (i&1) == 1 $$ into odds | |
summing i into total | |
maximizing i into max | |
minimizing i into min | |
finally $$ writeln("Stats: ", [min, max, total, evens, odds]) $$ | |
}); |
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
Stats: [2, 499, 126399, 229, 271] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment