Skip to content

Instantly share code, notes, and snippets.

@skatenerd
Last active December 20, 2015 23:58
Show Gist options
  • Save skatenerd/6216044 to your computer and use it in GitHub Desktop.
Save skatenerd/6216044 to your computer and use it in GitHub Desktop.
macros are weird.
(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..?
@skatenerd
Copy link
Author

that `s# is crazy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment