Advertisement
Guest User

Untitled

a guest
Aug 19th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defn apply-map-fn [f ks]
  2.   (let [params (->> (-> f meta :arglists first)
  3.                     (map keyword)
  4.                     (reduce #(conj %1 (ks %2)) [])
  5.                     (remove nil?))
  6.         f-args-count (-> f meta :arglists first count)
  7.         params-count (count params)]
  8.     (if (= f-args-count params-count)
  9.       (apply f params)
  10.       (throw (str "You passed " params-count " param(s) to " (-> f meta :name) " when it takes " f-args-count)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement