Created
April 10, 2017 14:39
-
-
Save DadgadCafe/18f27d0ecce55440a953e19f4c1e6a16 to your computer and use it in GitHub Desktop.
notes of problem on 4clojure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;;;;;;;; Last Element | |
;; (= (__ [1 2 3 4 5]) 5) | |
;; (= (__ '(5 4 3)) 3) | |
;; (= (__ ["b" "c" "d"]) "d") | |
#(nth % (- (count %) 1)) | |
#(nth % (dec (count %))) | |
;;;;;;;;;; Penultimate Element | |
;; (= (__ (list 1 2 3 4 5)) 4) | |
;; (= (__ ["a" "b" "c"]) "b") | |
;; (= (__ [[1 2] [3 4]]) [1 2]) | |
#(nth % (- (count %) 2)) | |
(comp second reverse) | |
;;;;;;;;;; Map Defaults | |
({:foo 1 :bar 2} :f 3) ; => 3 | |
;; (= (__ 0 [:a :b :c]) {:a 0 :b 0 :c 0}) | |
;; (= (__ "x" [1 2 3]) {1 "x" 2 "x" 3 "x"}) | |
;; (= (__ [:a :b] [:foo :bar]) {:foo [:a :b] :bar [:a :b]}) | |
#(apply hash-map (interleave %2 (repeat %1))) | |
;;;;;;;;;; todo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment