fold-bool.lisp 749 B

123456789101112131415161718192021222324
  1. (import compiler/optimise (fusion/defrule))
  2. ;; (not (/= x y)) => (= x y)
  3. (fusion/defrule (not (/= ?x ?y))
  4. (= ?x ?y))
  5. (fusion/defrule (cond [(/= ?x ?y) false] [true true])
  6. (= ?x ?y))
  7. ;; (not (= x y)) => (/= x y)
  8. (fusion/defrule (not (= ?x ?y))
  9. (/= ?x ?y))
  10. (fusion/defrule (cond [(= ?x ?y) false] [true true])
  11. (/= ?x ?y))
  12. ;; (unless (= x y) z) => (when (/= x y) z
  13. ;; It'd be nice to have z match 0..n statements, but the system doesn't
  14. ;; support that yet.
  15. (fusion/defrule (cond [(= ?x ?y)] [true ?z])
  16. (cond [(/= ?x ?y) ?z] [true]))
  17. ;; (unless (/= x y) z) => (when (= x y) z
  18. (fusion/defrule (cond [(/= ?x ?y)] [true ?z])
  19. (cond [(= ?x ?y) ?z] [true]))