dmm: (dynosaur)
[personal profile] dmm
(defn rec-map-mult [scalar rec-map-of-ns]
  (if (map? rec-map-of-ns)
      (into {}
            (map #(vector (first %1)
                          (rec-map-mult scalar (second %1))
                  )
                 rec-map-of-ns
            )
      )
      (if (number? rec-map-of-ns)
          (* scalar rec-map-of-ns)
          0
      )
  )
)

user=> (rec-map-mult  3 { :a 3 :b {:c 7 :d 9} })
{:a 9, :b {:c 21, :d 27}}
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

dmm: (Default)
Dataflow matrix machines (by Anhinga anhinga)

May 2025

S M T W T F S
    123
456 78910
11 121314151617
18192021222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 29th, 2025 05:34 am
Powered by Dreamwidth Studios