0

プロジェクトに CLIPS を使用しています。

属性モデルを持つこのテンプレート A と、属性モデルを持つ別のテンプレート B を使用しています。

したがって、私が達成したいのは属性モデルに基づいており、テンプレート B のファクトと同じ属性モデル値を持つテンプレート A のファクトを返します。

このフォーマットを使ってみた

  (find-all-facts((?a template_A)(?b template_B))
    (and
      //condition to be met
    )
  )

それは私に結果を与えますが、重複しているAとBの両方の結果を私に与えています..AまたはBのいずれかの重複しない値を返すようにするにはどうすればよいですか?

4

1 に答える 1

1
CLIPS> 
(deftemplate template_A
   (slot model))
CLIPS>    
(deftemplate template_B
   (slot model))
CLIPS>    
(deffacts start
   (template_A (model 1))
   (template_A (model 2))
   (template_A (model 3))
   (template_B (model 2))
   (template_B (model 3))
   (template_B (model 4)))
CLIPS>    
(deffunction extract-every-nth-value (?values ?start ?increment)
   (bind ?rv (create$))
   (while (<= ?start (length$ ?values))
      (bind ?rv (create$ ?rv (nth$ ?start ?values)))
      (bind ?start (+ ?start ?increment)))
   (return ?rv))
CLIPS> (reset)
CLIPS> (facts)
f-0     (initial-fact)
f-1     (template_A (model 1))
f-2     (template_A (model 2))
f-3     (template_A (model 3))
f-4     (template_B (model 2))
f-5     (template_B (model 3))
f-6     (template_B (model 4))
For a total of 7 facts.
CLIPS> 
(find-all-facts ((?a template_A)(?b template_B))
    (eq ?a:model ?b:model))
(<Fact-2> <Fact-4> <Fact-3> <Fact-5>)
CLIPS>     
(extract-every-nth-value
   (find-all-facts ((?a template_A)(?b template_B))
    (eq ?a:model ?b:model))
   1 2)
(<Fact-2> <Fact-3>)
CLIPS> 
于 2012-04-23T23:19:46.677 に答える