Created
September 27, 2014 19:41
-
-
Save kidpollo/f64f305bb3c6729096d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; 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)) | |
; ... | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; 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