Skip to content

Instantly share code, notes, and snippets.

@kidpollo
Created September 27, 2014 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kidpollo/f64f305bb3c6729096d9 to your computer and use it in GitHub Desktop.
Save kidpollo/f64f305bb3c6729096d9 to your computer and use it in GitHub Desktop.
;;;; francisco.clj
(ns francisco
(require [francisco.pacemaker :as pacemaker]))
(atom current-state-of-being
{:alive true
:body-parts {:heart {:current-heart-rate (rand-int 100)}}})
(while (:alive current-state-of-being)
; ...
(pacemaker/dont-let-heart-stop (get-in [:body-parts
:heart]
current-state-of-being))
; ...
)
;;;; francisco.pacemaker.clj
(ns francisco.pacemaker)
(def min-heart-rate 45)
(defn get-heart-rate [heart]
(:current-heart-rate heart))
(defn poke-the-heart-with-a-bit-of-electricity [heart]
(assoc heart :current-heart-rate (inc (get-heart-rate heart))))
(defn dont-let-heart-stop [current-heart]
(let [current-heart-rate (get-heart-rate current-heart)]
(when (<= min-heart-rate current-heart-rate)
(poke-the-heart-with-a-bit-of-electricity))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment