-
-
Save luxbock/fda8f2ee4e642903d532d1b34db902e5 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 get-apply | |
[m & fields] | |
(loop [this-m m | |
[f & fs] fields] | |
(when-let [v (get this-m f)] | |
(cond | |
(map? v) (recur v fs) | |
(ifn? v) (apply v fs) | |
:else v)))) | |
(defn get-rule | |
[rules & fields] | |
(or | |
(apply get-apply rules fields) | |
(apply get-apply rules :default (drop 2 fields)) | |
(throw (ex-info "Lookup failure!" {:fields fields})))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment