Skip to content

Instantly share code, notes, and snippets.

@jebberjeb
Last active December 19, 2015 12:29
Show Gist options
  • Save jebberjeb/5955136 to your computer and use it in GitHub Desktop.
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.
(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