Is it possible to modify the fact "?u" using a variable like the slot name, instead of a symbol?
(defrule R-1 ?u <- (user) ?f <- (question (answered no) (the-question ?q) (attribute ?attribute)) => (modify ?f (answered yes)) (modify ?u (?attribute 5)) )
You can't do this with facts, but you can with instances since the message argument to the send function can be a constant, variable, or expression.
CLIPS> (defclass EXAMPLE (is-a USER) (slot x) (slot y) (slot z)) CLIPS> (make-instance [x] of EXAMPLE (x 1) (y 2) (z 3)) [x] CLIPS> (send [x] print) [x] of EXAMPLE (x 1) (y 2) (z 3) CLIPS> (send [x] (sym-cat put- x) 5) 5 CLIPS> (send [x] print) [x] of EXAMPLE (x 5) (y 2) (z 3) CLIPS>
Log in to post a comment.
Is it possible to modify the fact "?u" using a variable like the slot name, instead of a symbol?
(defrule R-1
?u <- (user)
?f <- (question
(answered no)
(the-question ?q)
(attribute ?attribute))
=>
(modify ?f (answered yes))
(modify ?u (?attribute 5))
)
You can't do this with facts, but you can with instances since the message argument to the send function can be a constant, variable, or expression.