Skip to content

Instantly share code, notes, and snippets.

@yvern
Created January 20, 2023 18:58
Show Gist options
  • Save yvern/35705e32442bdb28fb32d9da67332919 to your computer and use it in GitHub Desktop.
Save yvern/35705e32442bdb28fb32d9da67332919 to your computer and use it in GitHub Desktop.
(ns yvern.hard-rule
(:require [clara.rules :refer [defrule insert!]]))
(def $ (comp val first))
(defrule all-together
[?middle <- :middle]
[:or
[:and [?max <- :top] [?min <- :bottom]]
[:and [?min <- :left] [?max <- :right]]]
=>
(cond
(<= ($ ?max) ($ ?middle))
(insert! {:fact-type :overflow})
(<= ($ ?middle) ($ ?min))
(insert! {:fact-type :underflow})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment