Last active
August 29, 2015 14:02
-
-
Save goloroden/97726ae346e08f3ada43 to your computer and use it in GitHub Desktop.
My first 'real' Lisp program…
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
(defun lottery () | |
(flet ((shuffle (list) | |
(let ((len (length list))) | |
(loop repeat len | |
do | |
(rotatef | |
(nth (random len) list) | |
(nth (random len) list)) | |
finally | |
(return list))))) | |
(sort (subseq (shuffle (loop for i from 1 to 49 collect i)) 0 6) #'<))) | |
(lottery) | |
;; => (5 6 17 21 35 37) |
lispm
commented
Jun 9, 2014
; Clojure
(take 6 (distinct (repeatedly #(inc (rand-int 49)))))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment