description | Concurrent propagator system implemented in Clojure |
owner | schulte.eric@gmail.com |
last change | Mon, 24 Jan 2011 16:42:06 +0000 (24 09:42 -0700) |
URL | git://repo.or.cz/propagator.git |
https://repo.or.cz/propagator.git | |
push URL | ssh://repo.or.cz/propagator.git |
https://repo.or.cz/propagator.git (learn more) | |
bundle info | propagator.git downloadable bundles |
content tags |
A concurrent propagator system implemented in Clojure. This simple project builds on the scheme propagator system from Gerald Sussman's The art of the Propagator.
We develop a programming model built on the idea that the basic computational elements are autonomous machines interconnected by shared cells through which they communicate. Each machine continuously examines the cells it is interested in, and adds information to some based on deductions it can make from information from the others. This model makes it easy to smoothly combine expression-oriented and constraint-based programming; it also easily accommodates implicit incremental distributed search in ordinary programs. This work builds on the original research of Guy Lewis Steele Jr. and was developed more recently with the help of Chris Hanson.
Major differences between this system and the one implemented in The art of the Propagator are that,
(note: this is an exploratory, educational implementation and isn't suitable for any sort of production application.)
This system is implemented in 26 lines of Clojure code in src/propagator.clj.
(in-ns 'propagator) (defcell guess 1) (defcell x 9) (defcell done false) (defcell margin 0.1) ;; check if we're close enough to a solution to cease improving (defpropagator enough [x guess] [done] (Thread/sleep 1000) ; sleep to allow observation of incremental calculation (if (< (abs (- (* guess guess) x)) @margin) true false)) ;; incrementally improve our guess (defpropagator heron [x done guess] [guess] (Thread/sleep 1000) (if done guess (/ (+ guess (/ x guess)) 2.0))) (comment ; after building the system (set-cell x 89) ; update the value of x (deref guess) ; immediately begin observing improvements in guess (deref guess))
Copyright (C) 2010 Eric Schulte
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
13 years ago | master | logtree |