0

ユーザーが特定の範囲内の値を入力すると、メッセージを返そうとしています。これは CLIPS で可能ですか? さらに、システムは 10 単位の値のみを受け入れる必要があります。

If the user types in a number less or equal to 10 it should say "A"
If the user types in a number greater than 10 and less than 40 it should say "B" 
- so it should only accept values 10,20,30,40

これは私がこれまでに持っているコードです:

(defrule b-a1
(b-a "a")
=>
(bind ?reply (get-text-from-user "How many points did you achieve?"))
(assert (b-a1 ?reply )))

(defrule b-a2
(b-a1 <= 10)
=>
(assert (conclusion "A")))

(defrule b-a2
(10 < b-a1 < 40)
=>
(assert (conclusion "B")))

これを機能させる方法についてのアイデアはありますか?

4

1 に答える 1

1
CLIPS> 
(defrule b-a1
   (b-a "a")
   =>
   (printout t "How many points did you achieve? ")
   (bind ?reply (read))
   (assert (b-a1 ?reply )))
CLIPS> 
(defrule b-a2
   (b-a1 ?v&:(<= ?v 10))
   =>
   (assert (conclusion "A")))
CLIPS> 
(defrule b-a2
   (b-a1 ?v&:(< 10 ?v)&:(< ?v 40))
   =>
   (assert (conclusion "B")))
CLIPS> (assert (b-a "a"))
<Fact-1>
CLIPS> (run)
How many points did you achieve? 24
CLIPS> (facts)
f-0     (initial-fact)
f-1     (b-a "a")
f-2     (b-a1 24)
f-3     (conclusion "B")
For a total of 4 facts.
CLIPS> 
于 2013-05-01T18:46:32.643 に答える