JESS: How do I assert ordered facts from a map
"Donald Winston" <[email protected]>
| Newsgroups | gmane.comp.java.jess |
|---|---|
| Message-ID | <32340_1281712308_o7DF7lWD032418_11AB230A-60B7-47AA-B7DC-78D053AE64B3@yahoo.com> |
Can anyone explain to me why this does not work? Why can't I use
(deffacts initial-facts
"Facts to trigger a few appropriate salient initialization rules."
(assert-request-parameters))
(defrule assert-request-parameters-rule
"Assert stored data one time."
(declare (salience 100))
?x <- (assert-request-parameters)
=>
(foreach ?key (((fetch request-parameter-map) keySet) iterator)
(build str-cat "(assert (" ?key " " ((fetch request-parameter-map) get ?key) "))"))
; why not (assert (?key ((fetch request-parameter-map) get ?key))))
(retract ?x))
(bind ?map (new java.util.HashMap))
(?map put one 1)
(?map put two 2)
(?map put three 3)
(store request-parameter-map ?map)
(reset)
(facts)
(run)
(facts)
Jess, the Rule Engine for the Java Platform
Copyright (C) 2008 Sandia Corporation
Jess Version 7.1p2 11/5/2008
This copy of Jess will expire in 207 day(s).
f-0 (MAIN::initial-fact)
f-1 (MAIN::assert-request-parameters)
For a total of 2 facts in module MAIN.
f-0 (MAIN::initial-fact)
For a total of 1 facts in module MAIN.