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
(ns om-tut.core | |
(:require [om.core :as om :include-macros true] | |
[om.dom :as dom :include-macros true] | |
[clojure.string :as string])) | |
(enable-console-print!) | |
(def app-state | |
(atom | |
{:people |
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
(def place-settings 5) | |
(def chopsticks (repeatedly place-settings #(ref true))) | |
(def philosophers (map #(agent %) (partition 2 1 chopsticks chopsticks))) | |
(defn sleep [] (Thread/sleep (rand-int 1000))) | |
(def eat sleep) | |
(def think sleep) | |
(defn toggle-chopsticks [cs pred?] | |
(dosync |