Last active
December 20, 2015 23:58
-
-
Save skatenerd/6216044 to your computer and use it in GitHub Desktop.
macros are weird.
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
(def a (lg/lvar 'a)) | |
(def b (lg/lvar 'b)) | |
(def lvars [a b]) | |
;simple attempt: | |
(lg/run* [q] | |
(fd/in a b (fd/interval 0 1)) | |
(lg/== q lvars)) | |
; this gives me the answer i want --> ([0 0] [0 1] [1 0] [1 1]) | |
;more complicated: | |
(lg/run* [q] | |
(doseq [lvar lvars] | |
(fd/in lvar (fd/interval 0 1))) | |
(lg/== q lvars)) | |
;this gives a null pointer exception | |
;i think it is because of how the run* macro is implemented. i am confused, because the goals are basically side-effect-producing. | |
;this is frustrating because I want to **programatically generate constraints**, which will be a pain if I can't use doseq. | |
;here is another failed attempt: | |
(defn bind-them [[lvar & lvars]] | |
(fd/in lvar (fd/interval 0 1)) | |
(if (not (empty? lvars)) | |
(recur (rest lvars)))) | |
(lg/run* [q] | |
(bind-them lvars) | |
(lg/== q lvars)) | |
;do you understand why the null pointer exception? | |
;i suppose the macro is my only option: trick the macro into thinking i've given it a list of explicit commands..? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
that `s# is crazy.