Skip to content

Instantly share code, notes, and snippets.

@ajorgensen
Last active December 30, 2015 12:59
Show Gist options
  • Save ajorgensen/7833049 to your computer and use it in GitHub Desktop.
Save ajorgensen/7833049 to your computer and use it in GitHub Desktop.
Pass predicate
(def predicate `(< 3 "?a"))
(def data [[1] [2] [3] [4]])
(defmacro foo
[data predicate]
`(<- ["?a"]
(data :> "?a")
(~@predicate)))
(?- (stdout) (foo data (eval predicate))) ;doesn't work
(?- (stdout) (foo data (< 3 "?a"))) ;works
@sritchie
Copy link

sritchie commented Dec 6, 2013

also, just do

(defn foo
  [data predicate]
  (<- [?a]
       (data :> ?a)
       pred))

Or use construct:

(defn foo
  [data & predicates]
  (apply construct ["?a"] [data :> "?a"] predicates))

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