Created
July 20, 2012 16:31
-
-
Save Idorobots/3151704 to your computer and use it in GitHub Desktop.
Common Lisp LOOP example and output
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
(let ((random (loop with max = 500 | |
for i from 0 to max | |
collect (random max)))) | |
(loop for i in random | |
counting (evenp i) into evens | |
counting (oddp i) into odds | |
summing i into total | |
maximizing i into max | |
minimizing i into min | |
finally (format t "Stats: ~A" | |
(list 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: (0 499 120808 261 240) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment