Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 0.26 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ;; hyone's solution to Merge with a Function
  2. ;; https://4clojure.com/problem/69
  3.  
  4. (fn my-merge-with [f & maps]
  5.   (reduce
  6.     (fn [a b]
  7.       (reduce
  8.         (fn [x [k v]]
  9.           (assoc x k (if (b k) (f v (b k)) v)))
  10.         b a))
  11.     (first maps) (rest maps)))