|
|
|
|
|
by lincpa
2619 days ago
|
|
In programming, data modeling is the most important. Convert(or design) data to hash-map, join (or merge) by key. it can write commonly used operations as functions, try to row (or col) operations as much as possible, and join all data only when necessary(reduce the row-join). ```clojure (def a {:a-id-01 {:a-name "a1"} :a-id-02 {:a-name "a2"}})
(def b {:b-id-01 {:a-id :a-id-01 :b-name "b2"} :b-id-02 {:a-id :a-id-02 :b-name "b2"}})
(->> b :b-id-01
:a-id
a
:a-name)
;=>;"a1" (let [x (b :b-id-01)] (->> x
:a-id
a
(merge x ,)))
;=>;{:a-id :a-id-01, ; :b-name "b2", ; :a-name "a1"} ``` |
|