断断续续的看了些Common Lisp的东西,主要是田春冰河翻译的那本《实用Common Lisp编程》,另外网上有人翻译了《ANSI Common Lisp》也有看,另一本《Common Lisp: A Gentle Introduction to Symbolic Computation》。总得写点东西,于是就写了这个双色球的小程序。
(defun select-red-ball (red-balls double-balls) (let (x) (setq x (elt red-balls (random (length red-balls)))) (vector-push x double-balls) (delete x red-balls)))
(defun create-double-balls() (let ((red-balls (make-array total-red-ball :fill-pointer0)) (blue-balls (make-array total-blue-ball :fill-pointer0)) (double-balls (make-array7:fill-pointer0))) (loop for i from 1 to total-red-ball do (vector-push i red-balls)) (loop for i from 1 to total-blue-ball do (vector-push i blue-balls)) (dotimes (n6) (select-red-ball red-balls double-balls)) (setq double-balls (sort double-balls #'<)) (vector-push (elt blue-balls (random16)) double-balls) (print double-balls))) (defun gen(n) (dotimes (i n) (create-double-balls)))