From 87d94c59365935b5a380d223a603195cabf25dc7 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Mon, 3 May 2010 14:51:12 -0600 Subject: [PATCH] more cleanup and prep for live demo --- propagator.org | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/propagator.org b/propagator.org index 2ffd07e..f68f65d 100644 --- a/propagator.org +++ b/propagator.org @@ -18,8 +18,8 @@ [name state] `(def ~name (agent ~state))) + ;; record keeping for graphing propagators (def prop-graph {}) - (defmacro remember-prop [name in-cells out-cells] `(def prop-graph (assoc prop-graph @@ -61,7 +61,7 @@ * extensions ** graphs of the propagator network draw a graph in a JFrame -#+begin_src clojure +#+begin_src clojure :tangle src/graphs.clj (in-ns 'propagator) (use 'vijual) (import '(javax.swing JFrame JPanel) @@ -81,7 +81,7 @@ draw a graph in a JFrame (paint [g] (.drawImage g img offset offset nil))))] (doto frame (.add panel) .pack (.setSize (+ offset width) (+ offset height)).show))) - + (defn graph-propagators [] (vec (set (apply concat @@ -92,7 +92,12 @@ draw a graph in a JFrame (map #(vec (list (name key) %)) (get hsh :out-cells))))) (keys prop-graph)))))) - (view (draw-directed-graph-image (graph-propagators))) + (defn view-network [] + (view (draw-directed-graph-image (graph-propagators)))) + + (defn clear-network [] + (def prop-graph {}) + (def frame (JFrame.))) #+end_src * usage @@ -115,9 +120,11 @@ draw a graph in a JFrame (cell margin 0.1) (propagator enough [x guess] [done] + (Thread/sleep 1000) (if (< (abs (- (* guess guess) x)) @margin) true false)) (propagator heron [x done guess] [guess] + (Thread/sleep 1000) (if done guess (/ (+ guess (/ x guess)) 2.0))) @@ -133,7 +140,7 @@ The =app= will dispatch the incoming data to input cell by the route at the end of the url, then there can be a couple of output cells which will render different views of the related data. -#+begin_src clojure +#+begin_src clojure :tangle src/web.clj (load-file "/home/eschulte/src/propagator/src/propagator.clj") (in-ns 'propagator) (use 'ring.adapter.jetty) -- 2.11.4.GIT