mirror of https://github.com/logseq/logseq
copy distinct-by to graph-parser
parent
db7975d09f
commit
1790223ed6
|
@ -8,8 +8,7 @@
|
||||||
;; stubbed in nbb
|
;; stubbed in nbb
|
||||||
com.lambdaisland/glogi {:mvn/version "1.1.144"}
|
com.lambdaisland/glogi {:mvn/version "1.1.144"}
|
||||||
;; built in to nbb
|
;; built in to nbb
|
||||||
cljs-bean/cljs-bean {:mvn/version "1.5.0"}
|
cljs-bean/cljs-bean {:mvn/version "1.5.0"}}
|
||||||
medley/medley {:mvn/version "1.4.0"}}
|
|
||||||
|
|
||||||
:aliases
|
:aliases
|
||||||
;; This runs tests with nodejs. Would be nice to run this with in a browser env
|
;; This runs tests with nodejs. Would be nice to run this with in a browser env
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
[clojure.edn :as edn]
|
[clojure.edn :as edn]
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[clojure.walk :as walk]
|
[clojure.walk :as walk]
|
||||||
[medley.core :as medley]
|
|
||||||
[logseq.graph-parser.log :as log]))
|
[logseq.graph-parser.log :as log]))
|
||||||
|
|
||||||
(defn safe-decode-uri-component
|
(defn safe-decode-uri-component
|
||||||
|
@ -158,9 +157,20 @@
|
||||||
(map string/capitalize)
|
(map string/capitalize)
|
||||||
(string/join " ")))
|
(string/join " ")))
|
||||||
|
|
||||||
|
|
||||||
(defn distinct-by
|
(defn distinct-by
|
||||||
[f col]
|
"Copy from medley"
|
||||||
(medley/distinct-by f (seq col)))
|
[f coll]
|
||||||
|
(let [step (fn step [xs seen]
|
||||||
|
(lazy-seq
|
||||||
|
((fn [[x :as xs] seen]
|
||||||
|
(when-let [s (seq xs)]
|
||||||
|
(let [fx (f x)]
|
||||||
|
(if (contains? seen fx)
|
||||||
|
(recur (rest s) seen)
|
||||||
|
(cons x (step (rest s) (conj seen fx)))))))
|
||||||
|
xs seen)))]
|
||||||
|
(step (seq coll) #{})))
|
||||||
|
|
||||||
(defn normalize-format
|
(defn normalize-format
|
||||||
[format]
|
[format]
|
||||||
|
|
Loading…
Reference in New Issue