Fork me on GitHub
#specter
<
2020-12-17
>
Ronny Li01:12:33

Hi, if I have two maps with similar nesting and keys, can I use specter to perform an operation on both simultaneously? For example, multiply values that have the exact same keys? Basically I'm looking for something like https://clojuredocs.org/clojure.core/merge-with but for an arbitrarily nested map

Ronny Li01:12:11

Here's an example:

{:price {"TSLA"
    {"2020-11-01" 400
    "2020-11-02" 425
    "2020-11-03" 420
    "2020-11-04" 430
    "2020-11-05" 430}
    "GOOG"
    {"2020-11-01" 500
    "2020-11-02" 525
    "2020-11-03" 520
    "2020-11-04" 530
    "2020-11-05" 530}}}

{:weight {"TSLA"
    {"2020-11-01" 0.5
    "2020-11-02" 0.6
    "2020-11-03" 0.3
    "2020-11-04" 0.4
    "2020-11-05" 0.7}
    "GOOG"
    {"2020-11-01" 0.4
    "2020-11-02" 0.425
    "2020-11-03" 0.420
    "2020-11-04" 0.43
    "2020-11-05" 0.43}}}
And my goal is to multiple :price and :weight together. How would I go about it with specter?