Last active
December 19, 2015 12:29
-
-
Save jebberjeb/5955136 to your computer and use it in GitHub Desktop.
This is that example from yesterday's TDD that was tripping me up. Looks easy here -- think I just need to do more apply (partial map foo) coll of colls.
This file contains 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
(def ->num {[" " | |
" |" | |
" |" | |
" "] 1 | |
[" _ " | |
" _|" | |
"|_ " | |
" "] 2 | |
[" _ " | |
" _|" | |
" _|" | |
" "] 3}) | |
(def lines [" _ _ " | |
" | _| _|" | |
" ||_ _|" | |
" " | |
" _ _ " | |
" | _| _|" | |
" ||_ _|" | |
" "]) | |
;; Condensed version of TDD workshop exercise | |
(prn (->> lines | |
(partition 4) | |
(map #(->> % | |
(map (partial re-seq #"...")) | |
(apply (partial map vector)) ;; <-- why? | |
(map ->num))))) | |
;;=> ((1 2 3) (1 2 3))) | |
;; Simplified example of the line I was troubled by | |
(prn (apply (partial map vector) [[1 4] [2 5] [3 6]])) | |
;;=> ([1 2 3] [4 5 6]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment