Pull #()s out into fns
This commit is contained in:
parent
355b9f9949
commit
6e4fd22fd4
|
@ -388,15 +388,16 @@
|
||||||
(throw (ex-info (show/show (interpret-ast (:expr ast) ctx)) {:ast ast})))
|
(throw (ex-info (show/show (interpret-ast (:expr ast) ctx)) {:ast ast})))
|
||||||
|
|
||||||
(defn- list-term [ctx]
|
(defn- list-term [ctx]
|
||||||
#(if (= (::ast/type %2) ::ast/splat)
|
(fn [list member]
|
||||||
(let [splatted (interpret-ast (:expr %2) ctx)
|
(if (= (::ast/type member) ::ast/splat)
|
||||||
|
(let [splatted (interpret-ast (:expr member) ctx)
|
||||||
splat-list? (and
|
splat-list? (and
|
||||||
(vector? splatted)
|
(vector? splatted)
|
||||||
(not (= (first splatted) ::data/tuple)))]
|
(not (= (first splatted) ::data/tuple)))]
|
||||||
(if splat-list?
|
(if splat-list?
|
||||||
(concat %1 splatted)
|
(concat list splatted)
|
||||||
(throw (ex-info "Cannot splat non-list into list" {:ast %2}))))
|
(throw (ex-info "Cannot splat non-list into list" {:ast member}))))
|
||||||
(concat %1 [(interpret-ast %2 ctx)])))
|
(concat list [(interpret-ast member ctx)]))))
|
||||||
|
|
||||||
(defn- interpret-list [ast ctx]
|
(defn- interpret-list [ast ctx]
|
||||||
(let [members (:members ast)]
|
(let [members (:members ast)]
|
||||||
|
@ -407,16 +408,16 @@
|
||||||
(defn- interpret-set [ast ctx])
|
(defn- interpret-set [ast ctx])
|
||||||
|
|
||||||
(defn- hash-term [ctx]
|
(defn- hash-term [ctx]
|
||||||
#(if (= (::ast/type %2) ::ast/splat)
|
(fn [hash member] (if (= (::ast/type member) ::ast/splat)
|
||||||
(let [splatted (interpret-ast (:expr %2) ctx)
|
(let [splatted (interpret-ast (:expr member) ctx)
|
||||||
splat-map? (and
|
splat-map? (and
|
||||||
(map? splatted)
|
(map? splatted)
|
||||||
(::data/hashmap splatted))]
|
(::data/hashmap splatted))]
|
||||||
(if splat-map?
|
(if splat-map?
|
||||||
(merge %1 splatted)
|
(merge hash splatted)
|
||||||
(throw (ex-info "Cannot splat non-hashmap into hashmap" {:ast %2}))))
|
(throw (ex-info "Cannot splat non-hashmap into hashmap" {:ast member}))))
|
||||||
(let [k (first %2) v (second %2)]
|
(let [k (first member) v (second member)]
|
||||||
(assoc %1 k (interpret-ast v ctx)))))
|
(assoc hash k (interpret-ast v ctx))))))
|
||||||
|
|
||||||
(defn- interpret-hash [ast ctx]
|
(defn- interpret-hash [ast ctx]
|
||||||
(let [members (:members ast)]
|
(let [members (:members ast)]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user