Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
The logic of sleep
(import [adderall.dsl [*]]
[human])
(require adderall.dsl)
(defn awake-too-longᵒ [last-sleep-time]
(project [last-sleep-time]
(if (> (- (time) last-sleep-time) 14)
#ss
#uu)))
(defn not-enough-coffeeᵒ [coffee-level]
(project [coffee-level]
(if (< coffee-level 0.1)
#uu
#ss)))
(run* [what-would-a-laptop-do?]
(fresh [last-sleep coffee-level]
(≡ last-sleep (.retrieve human.memory :last-sleep))
(≡ coffee-level (.retrieve human.memory :coffee-level))
(anyᵒ
(allᵒ
(awake-too-longᵒ last-sleep)
(not-enough-coffeeᵒ coffee-level)
(≡ what-would-a-laptop-do? :hibernate))
(allᵒ
(awake-too-longᵒ last-sleep)
(≡ what-would-a-laptop-do? :plug-in-to-power-charge))
(≡ what-would-a-laptop-do? :sleep))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment