How does not clause work in Datomic?
I am trying to find latitudes that fall between two inputs. My request:
(defn- latlngs-within-new-bounds [db a w] (d/q '[:find ?lat :in $ ?a ?w :where [ ?e :location/lat ?lat] [(>= ?lat ?a)] (not [(>= ?lat ?w)])] db a w))
My mistake:
3 Unhandled com.google.common.util.concurrent.UncheckedExecutionException
java.lang.RuntimeException: Unable to resolve symbol: ?lat in this
context
2 Caused by clojure.lang.Compiler$CompilerException
1 Caused by java.lang.RuntimeException
Unable to resolve symbol: ?lat in this context
Util.java: 221 clojure.lang.Util/runtimeException
Any help with understanding what is wrong with my request would be greatly appreciated. Bonus points if you can also use the Datomic Rules to split a portion of in-bounds
each half.
+3
source to share
1 answer
Your code seems to work for me with datomic-free 0.9.5173:
(defn- latlngs-within-new-bounds
[db a w]
(d/q '[:find ?lat
:in $ ?a ?w
:where
[ ?e :location/lat ?lat]
[(>= ?lat ?a)]
(not
[(>= ?lat ?w)])]
db a w))
(latlngs-within-new-bounds
[[1 :location/lat 1]
[2 :location/lat 2]
[3 :location/lat 3]
[4 :location/lat 4]
[4 :location/lat 5]]
2 4)
=> #{[2] [3]}
+1
source to share