#:g1: clojureでL-99 (P24 ロトくじ)

Posted 2008-10-16 03:21:00 GMT

-(http://www.ic.unicamp.br/~meidanis/courses/mc336/2006s2/funcional/L-99_Ninety-Nine_Lisp_Problems.html)
こういうランダムな場合に上手く条件をテストできる方法が知りたいと思ったり。

(defn
  #^{:doc "P24 (*) Lotto: Draw N different random numbers from the set 1..M."}
; ------------
  lotto-select
; ------------
  ([nums rng]
     (if (or (>= 0 rng) (>= 0 nums)) 
       nil
       (rnd-select (range 1 (+ 1 rng)) nums))))

comments powered by Disqus