Created
March 19, 2014 07:11
-
-
Save MarcoPolo/9636822 to your computer and use it in GitHub Desktop.
How to find the smallest number in a set of facts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(assert | |
(foo 3) | |
(foo 4) | |
(foo 6) | |
(foo 9) | |
(foo 2) | |
(foo 5)) | |
(defrule init-lowest | |
(not (lowest-foo ?)) | |
(foo ?a) | |
=> (assert (lowest-foo ?a))) | |
(defrule lowest | |
(declare (salience 1100)) | |
?foo <- (foo ?a) | |
?lowest <- (lowest-foo ?b) | |
(test (< ?a ?b)) | |
=> | |
(retract ?lowest) | |
(assert (lowest-foo ?a))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment