Skip to content

Commit

Permalink
move interpolate
Browse files Browse the repository at this point in the history
  • Loading branch information
pleasetrythisathome committed Nov 25, 2014
1 parent 45796a1 commit deeb8e0
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/bardo/interpolate.cljx
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,9 @@
[1 (_ :guard sequential?)] (take (count end) v)
[_ _] v))))))

(defprotocol IInterpolate (-interpolate [start end]))
(declare interpolate)

(defn interpolate [start end]
(let [wrapped (some->> [start end]
(apply wrap-nil)
(apply wrap-errors)
(apply wrap-infinite))]
(let [can-interpolate (mapv #(satisfies? IInterpolate %) wrapped)]
(if (apply = true can-interpolate)
((apply wrap-size wrapped) (apply -interpolate wrapped))
(do
(throw
(#+cljs js/Exception #+clj Exception. (str "Cannot interpolate between " start " and " end))))))))
(defprotocol IInterpolate (-interpolate [start end]))

(extend-protocol IInterpolate

Expand Down Expand Up @@ -140,3 +130,15 @@
(map k)
(apply interpolate)
(#(% t)))])))))

(defn interpolate [start end]
(let [wrapped (some->> [start end]
(apply wrap-nil)
(apply wrap-errors)
(apply wrap-infinite))]
(let [can-interpolate (mapv #(satisfies? IInterpolate %) wrapped)]
(if (apply = true can-interpolate)
((apply wrap-size wrapped) (apply -interpolate wrapped))
(do
(throw
(#+cljs js/Exception #+clj Exception. (str "Cannot interpolate between " start " and " end))))))))

0 comments on commit deeb8e0

Please # to comment.