2004 | 12 |
2005 | 01 | 02 | 07 | 10 | 11 |
2006 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2007 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2008 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2009 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2010 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2011 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 11 |
2005 | 01 | 02 | 07 | 10 | 11 |
2006 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2007 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2008 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2009 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2010 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2011 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 11 |
2008-10-22
ClojureでL-99 (P26 指定した個数を抜き出す組み合わせ)
Arcの[]や、Clojureの#()は、便利なんですが、更に進んで、mapの等で、`#(~(first coll) ~@%)みたいに書きたくなることが結構あります。どっちも今のところできません。というか、筋道立てて考えるとそもそも無理な相談という感じなのですが。
(defn #^{:doc "P26 (**) Generate the combinations of K distinct objects chosen from the N elements of a list" :test (do (test= (combination 0 [1 2 3]) []) (test= (combination 88 []) []) (test= (count (combination 3 (range 12))) 220))} combination ([num coll] (cond (or (empty? coll) (>= 0 num)) [] (= 1 num) (map list coll) :else `(~@(map #(cons (first coll) %) (combination (- num 1) (rest coll))) ~@(combination num (rest coll))))))
コメントを書く