Last active
August 29, 2015 13:58
-
-
Save guilespi/10035399 to your computer and use it in GitHub Desktop.
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
(defn validate-mappings | |
"Validates each mapped import is for an | |
existent field in the specified company" | |
[fields headers mappings] | |
(letfn [(found? [list element] (< (.indexOf list element) 0))] | |
(filter (fn [[header field]] | |
(or (found? headers header) | |
(found? fields field))) | |
mappings))) | |
;mappings is a map from csv header to schema field {"header" "db field"} | |
;header is a list of header field names ["h1" "h2" "h3"] | |
;fields is a list of db field names ["f1" "f2 "f3"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's weird that you use
(nth % 0)
instead of first, presumably for performance reasons, but then you fail to type hint list in maps? Also, why partial? Why not just(comp name #(nth % 0))
Where you trying to partial nth, then realized you needed to bind the second argument instead of the first one and finally forgot to delete partial?I'd make maps? return boolean and take the element, also rename header function argument to headers then