--- a/package.lisp Sat Sep 24 17:33:22 2016 +0000
+++ b/package.lisp Mon Sep 26 12:28:06 2016 +0000
@@ -82,6 +82,7 @@
#:invoke-query
#:invoke-query-all
#:invoke-query-map
+ #:invoke-query-for
#:invoke-query-do
#:invoke-query-find
#:invoke-prove
@@ -89,6 +90,7 @@
#:query
#:query-all
#:query-map
+ #:query-for
#:query-do
#:query-find
#:prove
--- a/src/ui.lisp Sat Sep 24 17:33:22 2016 +0000
+++ b/src/ui.lisp Mon Sep 26 12:28:06 2016 +0000
@@ -140,6 +140,13 @@
nil))
(nreverse results)))
+(define-invocation (invoke-query-for invoke-query-for-aot) (variable)
+ (let ((results nil))
+ (invoke (lambda (result)
+ (push (getf result variable) results)
+ nil))
+ (nreverse results)))
+
(define-invocation (invoke-query-do invoke-query-do-aot) (function)
(invoke (lambda (result)
(funcall function result)
@@ -178,6 +185,9 @@
(defmacro query-map (database function &rest terms)
`(invoke-query-map ,database ,function ,@(quote-terms terms)))
+(defmacro query-for (database variable &rest terms)
+ `(invoke-query-for ,database ',variable ,@(quote-terms terms)))
+
(defmacro query-do (database function &rest terms)
`(invoke-query-do ,database ,function ,@(quote-terms terms)))
@@ -219,6 +229,8 @@
(define-invocation-compiler-macro invoke-query-map invoke-query-map-aot (database function))
+(define-invocation-compiler-macro invoke-query-for invoke-query-for-aot (database variable))
+
(define-invocation-compiler-macro invoke-query-do invoke-query-do-aot (database function))
(define-invocation-compiler-macro invoke-query-find invoke-query-find-aot (database predicate))