mirror of
https://github.com/tonsky/FiraCode.git
synced 2024-08-17 08:50:47 +03:00
15 lines
314 B
Clojure
15 lines
314 B
Clojure
(ns fira-code.coll)
|
|
|
|
|
|
(defn index-of [pred xs]
|
|
(let [res (reduce (fn [i x] (if (pred x) (reduced i) (inc i))) 0 xs)]
|
|
(assert (< res (count xs)) "Nothing found")
|
|
res))
|
|
|
|
|
|
(defn group-by-to [key-fn value-fn xs]
|
|
(reduce-kv
|
|
(fn [m k vs]
|
|
(assoc m k (value-fn vs)))
|
|
{}
|
|
(group-by key-fn xs))) |