Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; lotto.lisp is a (Common) Lisp program by Chris Clarke 01.08.2018
- ; purpose: choose 6 unique random balls in range 1..59
- (setq highest 59) ; 59 for national lottery
- (setq nballs 6) ; 6 for national lottery
- (setf *random-state* (make-random-state t))
- ; # this initializes the global random state
- (setf my-array (make-array highest))
- (setf chosen-array (make-array nballs))
- (dotimes (x highest)
- (setf (aref my-array x) (+ 1 x))
- ; my-array holds numbers 1 to 59
- )
- (dotimes (n nballs)
- (setq r (random highest))
- (setf (aref chosen-array n) (aref my-array r))
- (setq highest (- highest 1))
- (setf (aref my-array r) (aref my-array highest))
- )
- (write (sort chosen-array #'<))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement