Public Vars

Back

merge-with (clj)

(source)

function

(merge-with f & maps)
Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping(s) from the latter (left-to-right) will be combined with the mapping in the result by calling (f val-in-result val-in-latter).

Examples

typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
  "Type annotations for the base Clojure distribution."
  #?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
  (:require [clojure.core :as cc]
            [typed.clojure :as t]
            #?(:clj [typed.ann-macros.clojure :as macros])
            #?(:clj typed.ann.clojure.jvm) ;; jvm annotations
            #?(:clj clojure.core.typed))
  #?(:clj
     (:import (clojure.lang PersistentHashSet PersistentList
                            APersistentMap #_IPersistentCollection
                            #_ITransientSet
                            IRef)
              (java.util Comparator Collection))))

cc/merge-with (t/All [k v] (t/IFn [[v v :-> v] nil :* :-> nil]
                                  [[v v :-> v] (t/Map k v) :* :-> (t/Map k v)]
                                  [[v v :-> v] (t/Option (t/Map k v)) :* :-> (t/Option (t/Map k v))]))
re-path/studio
(ns renderer.frame.events
  (:require
   [clojure.core.matrix :as mat]
   [re-frame.core :as rf]
   [renderer.element.handlers :as el]
   [renderer.frame.handlers :as handlers]
   [renderer.utils.units :as units]))

(rf/reg-event-db
 :frame/resize
 (fn [{content-rect :content-rect :as db} [_ updated-content-rect]]
   (let [offset (-> (merge-with - content-rect updated-content-rect)
                    (select-keys [:width :height]))
         pan (mat/div [(:width offset) (:height offset)] 2)]
     (-> db
         (assoc :content-rect updated-content-rect)
         (handlers/pan pan)))))
yetanalytics/dave
(ns com.yetanalytics.dave.ui.app.workbook.data
  (:require [re-frame.core :as re-frame]
            [com.yetanalytics.dave.workbook.data :as data]
            [com.yetanalytics.dave.workbook.data.state :as state]
            [com.yetanalytics.dave.workbook.data.lrs.client
             :as lrs-client]
            [clojure.core.async :as a :include-macros true]
            [clojure.spec.alpha :as s]
            [goog.string :refer [format]]
            [goog.string.format]))

(re-frame/reg-event-fx
 ::ensure*
 (fn [{:keys [db] :as ctx} [_ workbook-id]]
   (if-let [data (get-in db [:workbooks
                             workbook-id
                             :data])]
     (if (s/valid? data/data-spec data)
       (if (:loading? data)
         {}
         (merge-with conj
                     {:db (assoc-in db [:workbooks
                                        workbook-id
                                        :data
                                        :loading?]
                                    true)}
                     ;; Ensure the timer is started if this is an LRS
                     (when (= (:type data) ::data/lrs)
                       {:dispatch-timer [[::ensure workbook-id]
                                         [::ensure workbook-id]
                                         10000]})
                     (fetch-fx workbook-id data db)))
       (.warn js/console "Skipped invalid Data source"))
     ;; Stop the timer if the data isn't present
     {:stop-timer [::ensure workbook-id]})))
helins/void.cljc
  (:require [clojure.core :as clj]
            [clojure.test :as t]
            [helins.void  :as void])
  (:refer-clojure :exclude [assoc
                            assoc-in
                            merge
                            merge-with
                            update
                            update-in]))

  ;; Tests `void/merge-with*"