Skip to content

Instantly share code, notes, and snippets.

View serioga's full-sized avatar

Sergey Trofimov serioga

View GitHub Profile
@serioga
serioga / map_entries.clj
Last active May 6, 2022 06:54
Create map from sequence using transducer
(ns map-entries
(:import (clojure.lang MapEntry)))
(defn map-entries
"Returns transducer collecting map-entries from the sequence of keys/values.
Map key is `(kf k)` or just key if `kf` is nil. Map value is `(vf k v)` or
just value if `vf` is nil. Raises exception in case of odd amount of elements
in the input sequence."
([] (map-entries nil nil))
([kf] (map-entries kf nil))
@serioga
serioga / exception.clj
Created August 3, 2023 14:11
Helper functions to work with exceptions
(ns lib.clojure.exception
(:require [clojure.test :as test]
[lib.clojure-string.core :as string']
[lib.clojure.lang :as lang])
(:import (clojure.lang Associative ExceptionInfo)))
(set! *warn-on-reflection* true)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The deps.edn file describes the information needed to build a classpath.
;;
;; When using the `clojure` or `clj` script, there are several deps.edn files
;; that are combined:
;; - install-level
;; - user level (this file)
;; - project level (current directory when invoked)
;;
;; For all attributes other than :paths, these config files are merged left to right.
;; Only the last :paths is kept and others are dropped.