Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Clojure 使用instaparse动态生成clara规则时遇到问题_Clojure_Rule Engine_Clojure Java Interop_Plumatic Schema_Instaparse - Fatal编程技术网

Clojure 使用instaparse动态生成clara规则时遇到问题

Clojure 使用instaparse动态生成clara规则时遇到问题,clojure,rule-engine,clojure-java-interop,plumatic-schema,instaparse,Clojure,Rule Engine,Clojure Java Interop,Plumatic Schema,Instaparse,我遵循了这个示例,我们使用Clara和instaparse来使用DSL并生成规则 除了一个问题外,一切都如我所料。我无法从lhs中表示的条件访问变量绑定并在rhs中使用它。 例如,下面是上面示例中的代码片段 (def shopping-transforms {:NUMBER #(Integer/parseInt %) :OPERATOR operators :FACTTYPE fact-types :CONDITION (fn [fact-type field operat

我遵循了这个示例,我们使用Clara和instaparse来使用DSL并生成规则

除了一个问题外,一切都如我所料。我无法从lhs中表示的条件访问变量绑定并在rhs中使用它。 例如,下面是上面示例中的代码片段

(def shopping-transforms
  {:NUMBER #(Integer/parseInt %)
   :OPERATOR operators
   :FACTTYPE fact-types
   :CONDITION (fn [fact-type field operator value]
                {:type fact-type
                 :constraints [(list operator (symbol field) value)]})

   ;; Convert promotion strings to keywords.
   :PROMOTIONTYPE keyword

   :DISCOUNT (fn [name percent & conditions]
               {:name name
                :lhs conditions
                :rhs `(insert! (->Discount ~name ~percent))})

   :PROMOTION (fn [name promotion-type & conditions]
                {:name name
                 :lhs conditions
                 :rhs `(insert! (->Promotion ~name ~promotion-type))})})
现在,如果我需要从lhs访问Customer name属性,并在rhs中的插入操作中使用它,我将如何修改上述转换函数以实现相同的功能

我需要编写一个转换函数,该函数应该给出一个类似于下面的规则

(defrule temperature-alert
  "Issue a temperature alert. This rule joins the current temperature with the location
   and gathers additional information to fire an alert with context."
  [CurrentTemperature (> value high-threshold)
                      (= ?location-id location)
                      (= ?value value)]

  [Location (= ?location-id id)
            (= ?sector sector)]
  =>
  (alert-temperature! ?value ?location-id ?sector))