Comment detail

ビンゴの結果を整形表示 (Nested Flatten)
bingo関数自体#2289から少し変更しました。
(print-bingo (bingo 25))
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
(defun bingo (n)
  (let ((*random-state* (make-random-state t)))
    (loop repeat n
          for rand = (loop 
                       (let ((rand (1+ (random n))))
                         (if (not (member rand lst))
                           (return rand))))
          collect rand into lst
          finally (return lst))))

(defun print-bingo (lst)
  (let ((index 0)
        (format-string (concatenate 
                         'string
                         "~{~"
                         (princ-to-string (1+ (length (princ-to-string (length lst)))))
                         "d~}~%" )))
    (loop for elements on lst by #'(lambda (x) (nthcdr 10 x))
          do (loop repeat 10
                   for e in elements
                   collect (incf index) into column-name
                   collect e into column-value
                   finally (format t format-string column-name)
                           (format t format-string column-value)
                           (terpri)))))

Index

Feed

Other

Link

Pathtraq

loading...