Skip to content

Commit

Permalink
Update some more methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Darrick Wiebe committed Aug 27, 2012
1 parent 4ed27de commit 4476cd3
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/pacer.clj
@@ -1,27 +1,28 @@
(ns pacer (ns pacer
(:use [clojure.pprint :only [pprint]] (:use [clojure.pprint :only [pprint]]
pacer.step)) pacer.step
))


(defn simple-encoder [] { :encode nil :decode nil }) (defn simple-encoder [] { :encode nil :decode nil })


(defn show (defn show
"Show an easy to read" "Show an easy to read"
[route] [route]
(->> route (->> route
(map describe-step) (map str)
(clojure.string/join " -> "))) (clojure.string/join " -> ")))


(defn- pipe-from-step [in step] (defn- pipe-from-step [in step]
(cond (cond
(:pipe step) (doto ((:pipe step) in) (satisfies? pacer.step/BuildPipe step) (doto (build-pipe step in)
(.setStarts (:pipe in (:source in)))) (.setStarts (:pipe in (:source in))))
(:iterator step) ((:iterator step) (:pipe in (:source in))) (satisfies? pacer.step/BuildIterator step) (iterator step (:pipe in (:source in)))
:else (throw (Exception. "Don't know how to build step")))) :else (throw (Exception. "Don't know how to build step"))))


(defn build-pipeline [[source & route]] (defn build-pipeline [[source & route]]
(if route (if route
(reduce (fn [in step] (reduce (fn [in step]
(check-step in step) (check step in)
{ :pipe (pipe-from-step in step) { :pipe (pipe-from-step in step)
:type (:type step (:type in)) :type (:type step (:type in))
:route (conj (:route in) step)}) :route (conj (:route in) step)})
Expand All @@ -45,7 +46,7 @@


(comment (comment
(route g v (loop (out-e :x) in-v :max 5 :while ??)) (route g v (loop (out-e :x) in-v :max 5 :while ??))
(route g v (loop { max: 5 } (out-e :x) in-v)) (route g v (loop { :max 5 } (out-e :x) in-v))
(route g v (loop (route g v (loop
(fn [v path loop emit] (loop) (emit path)) (fn [v path loop emit] (loop) (emit path))
; fn could use CPS. would that cause stack overflow? ; fn could use CPS. would that cause stack overflow?
Expand Down

0 comments on commit 4476cd3

Please sign in to comment.