Eddie_1337

SBC - L10

Dec 22nd, 2021
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. (deffacts F1
  2. (multime A 1 2 3 4 5)
  3. (multime B 2 3 4)
  4. (multime R)
  5. (multime D)
  6. (lista 1 8 2 7 3 4 9 5)
  7. (listaPare)
  8. )
  9.  
  10. (defrule R1
  11. (multime A $? ?x $?)
  12. (not(multime B $? ?x $?))
  13. ?a <- (multime D $?elem)
  14. (not (multime D $? ?x $?))
  15. =>
  16. (retract ?a)
  17. (assert (multime D $?elem ?x))
  18. )
  19.  
  20. (defrule R2
  21. ?a <- (lista $?el1 ?x $?el2 ?y $?el3)
  22. (test (> ?x ?y))
  23. =>
  24. (retract ?a)
  25. (assert (lista $?el1 ?y $?el2 ?x $?el3))
  26. )
  27.  
  28. (defrule R3
  29. ?a <- (listaPare $?el1)
  30. ?b <- (lista $?el2 ?x $?el3)
  31. (test (evenp ?x))
  32. =>
  33. (retract ?a ?b)
  34. (assert (listaPare $?el1 ?x))
  35. (assert (lista $?el2 $?el3))
  36. )
Advertisement
Add Comment
Please, Sign In to add comment