brave clojure 3

[Brave Clojure #5] 챕터 4 연습문제

챕터 4 연습문제를 풀었습니다. ;;; ex 4.1 (def result (glitter-filter 3 (mapify (parse (slurp filename))))) (map :name result) ;; => ("Edward Cullen" "Jacob Black" "Carlisle Cullen") ;;; ex 4.2 (defn append [[car & cdr] new-suspect] (if car (cons car (lazy-seq (append cdr new-suspect))) (list new-suspect))) (append '() 1) ;; => (1) (append '(1 2 3 4) 5) ;; => (1 2 3 4 5) ;;; ex 4.3 (def validators {:..

[Brave Clojure #4] reduce로 map, filter, some 구현하기

map의 설명을 마치 고 저자는 이렇게 말합니다. "If you want an exercise that will really blow your hair back, try implementing map using reduce, and then do the same for filter and some after you read about them later in this chapter." 안해 볼 수 없겠죠 (defn map-by-reduce [f xs] (seq (reduce #(conj %1 (f %2)) [] xs))) (map-by-reduce inc [1 2 3 4]) ;; => (2 3 4 5) (def food-journal [{:month 1 :day 1 :human 5.3 :critter 2..