gpt4 book ai didi

clojure - not 子句在 Datomic 中如何工作?

转载 作者:行者123 更新时间:2023-12-02 03:26:03 25 4
gpt4 key购买 nike

我试图找到落在两个输入之间的纬度。我的查询:

(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))

我的错误:

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

如果您能帮助我理解我的查询有什么问题,我们将不胜感激。如果您还可以使用 Datomic 规则分解出每一半的 in-bounds 部分,则可加分。

最佳答案

您的代码似乎适用于无数据的 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]}

关于clojure - not 子句在 Datomic 中如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30229209/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com