(deffacts dane (lista -16 19 -3 27 -44 3 14 -15 11 8 9 -10) ; (zakres ? ?) TEN FAKT ZOSTANIE WCZYTANY Z KLAWIATURY!!! (ilew 0) (ilepoza 0) ) (defrule czytaj (not (dane ? ?)) => (printout t "Podaje zakres w postaci dwoch liczb: ") (assert (dane (explode$ (readline)))) ; trzeba wpisywac w jednym wierszu!!! ) (defrule sprawdzaj1 ?i<-(dane ?l ?p) (or (test (not (numberp ?l))) (test (not (numberp ?p))) ) => (retract ?i) (printout t "Bledny zakres!!!" crlf) ) (defrule sprawdzaj2 (dane ?l ?p) (test (numberp ?l)) (test (numberp ?p)) (test (<= ?l ?p)) => (assert (zakres ?l ?p)) ) (defrule sprawdzaj3 (dane ?l ?p) (test (numberp ?l)) (test (numberp ?p)) (test (> ?l ?p)) => (assert (zakres ?p ?l)) ) (defrule wewnatrz ?i<-(lista ?x $?reszta) (zakres ?l ?p) (test (and (<= ?l ?x)(<= ?x ?p))) ?ii<-(ilew ?ile) => (retract ?i ?ii) (assert (lista $?reszta)) (assert (ilew (+ ?ile 1))) ) (defrule zewnatrz ?i<-(lista ?x $?reszta) (zakres ?l ?p) (test (or (< ?x ?l)(< ?p ?x))) ?ii<-(ilepoza ?ile) => (retract ?i ?ii) (assert (lista $?reszta)) (assert (ilepoza (+ ?ile 1))) )