-
-
Save luxbock/4eb81767e6bb1f6169b4fb12ec8b9356 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(transform | |
[ALL | |
(collect-one :foo) | |
(collect-one :bar)] | |
(fn [foo bar _] | |
(transform [REST ALL] | |
#(map (partial + foo) %) | |
bar)) | |
[{:foo 1 :bar [[10] [2 3] [20 30]]} | |
{:foo 2 :bar [[10] [4 5] [40 50]]} | |
{:foo 3 :bar [[10] [6 7] [60 70]]}]) | |
;; => [[[10] [3 4] [21 31]] [[10] [6 7] [42 52]] [[10] [9 10] [63 73]]] | |
(mapv (fn [{:keys [foo bar]}] | |
(into [(first bar)] | |
(map #(mapv (partial + foo) %)) | |
(rest bar))) | |
[{:foo 1 :bar [[10] [2 3] [20 30]]} | |
{:foo 2 :bar [[10] [4 5] [40 50]]} | |
{:foo 3 :bar [[10] [6 7] [60 70]]}]) | |
;; => [[[10] [3 4] [21 31]] [[10] [6 7] [42 52]] [[10] [9 10] [63 73]]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment