2011-10-09から1日間の記事一覧
組み合わせ生成関数(無限シーケンス対応版)を作ってみました。 ;; Ver.1 (defn- combinations* [xs combs] (when-first [x xs] (let [new-combs (map (fn [c] (conj c x)), combs)] (lazy-cat new-combs (combinations* (rest xs) (concat combs new-combs…
組み合わせ生成関数(無限シーケンス対応版)を作ってみました。 ;; Ver.1 (defn- combinations* [xs combs] (when-first [x xs] (let [new-combs (map (fn [c] (conj c x)), combs)] (lazy-cat new-combs (combinations* (rest xs) (concat combs new-combs…