20 lines
375 B
Text
20 lines
375 B
Text
(deffacts initial-state
|
|
(door-count 100)
|
|
)
|
|
|
|
(deffunction is-square
|
|
(?num)
|
|
(= (sqrt ?num) (integer (sqrt ?num)))
|
|
)
|
|
|
|
(defrule check-doors
|
|
(door-count ?count)
|
|
=>
|
|
(printout t "These doors are open:" crlf)
|
|
(loop-for-count (?num 1 ?count) do
|
|
(if (is-square ?num) then
|
|
(printout t ?num " ")
|
|
)
|
|
)
|
|
(printout t crlf "All other doors are closed." crlf)
|
|
)
|