Created
September 26, 2019 16:35
-
-
Save eraserhd/7af9d44501165acef18f5acfc7c80137 to your computer and use it in GitHub Desktop.
Small but nice win for Meander
This file contains hidden or 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
(doseq [attr #{"asset-location" "brand-name" "name" "uuid"}] | |
(eval | |
(m/subst | |
(defrule ~(symbol (str "Branding-" attr)) | |
[EAV (= e '?e) (= a ~(keyword "brand" attr)) (= v '?v)] | |
=> | |
(synthesize! '?e ~(keyword "branding" attr) '?v))))) |
This file contains hidden or 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
(doseq [attr #{"branding" "full-name" "uuid"}] | |
(eval | |
`(defrule ~(symbol (str "School-" attr)) | |
[EAV (= ~'e ?e#) (= ~'a :educational-organization/type) (= ~'v "SCHOOL")] | |
[EAV (= ~'e ?e#) (= ~'a ~(keyword "educational-organization" attr)) (= ~'v ?v#)] | |
~'=> | |
(synthesize! ?e# ~(keyword "school" attr) ?v#)))) |
I think you can also do
(doseq [?attr #{"asset-location" "brand-name" "name" "uuid"}]
(eval
(m/subst
(defrule (m/symbol (m/app str "Branding-" ?attr))
[EAV (= e '?e) (= a (m/keyword "brand" ?attr)) (= v '?v)]
=>
(synthesize! '?e (m/keyword "branding" ?attr) '?v)))))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The win: not needing so much escaping.