2010-06-01から1日間の記事一覧
関数型でやるとこんな感じ? (defn insert [sorted-coll val] (concat (filter #(> val %) sorted-coll) [val] (filter #(<= val %) sorted-coll))) (defn insertion-sort [coll] (loop [vals (rest coll) sorted-coll (list (first coll))] (if (empty? val…
関数型でやるとこんな感じ? (defn insert [sorted-coll val] (concat (filter #(> val %) sorted-coll) [val] (filter #(<= val %) sorted-coll))) (defn insertion-sort [coll] (loop [vals (rest coll) sorted-coll (list (first coll))] (if (empty? val…