Skip to content

Instantly share code, notes, and snippets.

@Idorobots
Created July 20, 2012 16:33
Show Gist options
  • Save Idorobots/3151713 to your computer and use it in GitHub Desktop.
Save Idorobots/3151713 to your computer and use it in GitHub Desktop.
Common Lisp LOOP in the D programming language
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]) $$
});
Stats: [2, 499, 126399, 229, 271]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment