Review comment: move assoc-if to utils.

This commit is contained in:
Richard Newman 2016-08-30 13:17:44 -07:00
parent 6fbd63fed2
commit ae65ba14fb
2 changed files with 16 additions and 16 deletions

View file

@ -40,19 +40,6 @@
:db.install/_attribute :db.part/db}
])
(defn assoc-if
([m k v]
(if v
(assoc m k v)
m))
([m k v & kvs]
(if kvs
(let [[kk vv & remainder] kvs]
(apply assoc-if
(assoc-if m k v)
kk vv remainder))
(assoc-if m k v))))
(defn- place->entity [[id rows]]
(let [title (:title (first rows))
@ -61,9 +48,9 @@
:page/guid (:guid (first rows))}
visits (keep :visit_date rows)]
(assoc-if required
:page/title title
:page/visitAt visits)))
(util/assoc-if required
:page/title title
:page/visitAt visits)))
(defn import-titles [conn places-connection]
(go-pair

View file

@ -73,6 +73,19 @@
[m path v]
(concat-in m path [v]))
(defn assoc-if
([m k v]
(if v
(assoc m k v)
m))
([m k v & kvs]
(if kvs
(let [[kk vv & remainder] kvs]
(apply assoc-if
(assoc-if m k v)
kk vv remainder))
(assoc-if m k v))))
(defmacro while-let [binding & forms]
`(loop []
(when-let ~binding