2014-07-08から1日間の記事一覧

Adam Bardさん特選記事

My Top Clojure Articles Adam Bardさんが書いたブログ記事のなかから、特選記事をまとめたものです。

4clojure #62 Re-implement Iterate

4clojure #62 Re-implement Iterate 関数fと初期値xをとり、 無限な遅延シーケンスx, (f x), (f (f x)), (f (f (f x)))...を返す関数を作る。 ※ iterateは使用禁止。 (= (take 5 (__ #(* 2 %) 1)) [1 2 4 8 16]) (= (take 100 (__ inc 0)) (take 100 (range)…

4clojure #61 Map Construction

4clojure #61 Map Construction ベクタのkeysとvaluesをとり、それらからマップを生成する関数を作る。 ※ zipmapは使用禁止。 (= (__ [:a :b :c] [1 2 3]) {:a 1, :b 2, :c 3}) (= (__ [1 2 3 4] ["one" "two" "three"]) {1 "one", 2 "two", 3 "three"}) (= …

4clojure #60 Sequence Reductions

4clojure #60 Sequence Reductions reduceのような動きをする関数を書く。 ただし、縮小する各中間の値を返すこと。 2か3引数をとり、遅延シーケンスを返すこと。 ※ reductions使用禁止 reductionsを使えばそのまま解決できました。 (= (take 5 (__ + (ran…