From 10dc34636bac3f02c8b22fcf9d58eff8b09594c0 Mon Sep 17 00:00:00 2001 From: Arne Brasseur Date: Mon, 22 Apr 2019 15:50:35 +0200 Subject: [PATCH 1/2] Use seek instead of find, the latter already exists in clojure.core --- src/refactor_nrepl/ns/clean_ns.clj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/refactor_nrepl/ns/clean_ns.clj b/src/refactor_nrepl/ns/clean_ns.clj index ae828432..ff3bca1b 100644 --- a/src/refactor_nrepl/ns/clean_ns.clj +++ b/src/refactor_nrepl/ns/clean_ns.clj @@ -36,13 +36,13 @@ (assert-no-exclude-clause (core/get-ns-component ns-form :use)) ns-form) -(defn- find +(defn- seek "Find the first element in coll that satisfies pred?" [pred? coll] (reduce (fn [_ x] (when (pred? x) (reduced x))) nil coll)) (defn clean-ns [{:keys [path relative-path]}] - (let [path (find #(and % (.exists (io/file %))) + (let [path (seek #(and % (.exists (io/file %))) [path relative-path])] (assert (core/source-file? path)) ;; Prefix notation not supported in cljs. From 3175e251ca46b3f7862420791855e07c2e1230a4 Mon Sep 17 00:00:00 2001 From: Arne Brasseur Date: Tue, 23 Apr 2019 15:06:28 +0200 Subject: [PATCH 2/2] Use some as requested --- src/refactor_nrepl/ns/clean_ns.clj | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/refactor_nrepl/ns/clean_ns.clj b/src/refactor_nrepl/ns/clean_ns.clj index ff3bca1b..a500d701 100644 --- a/src/refactor_nrepl/ns/clean_ns.clj +++ b/src/refactor_nrepl/ns/clean_ns.clj @@ -36,13 +36,10 @@ (assert-no-exclude-clause (core/get-ns-component ns-form :use)) ns-form) -(defn- seek - "Find the first element in coll that satisfies pred?" - [pred? coll] - (reduce (fn [_ x] (when (pred? x) (reduced x))) nil coll)) - (defn clean-ns [{:keys [path relative-path]}] - (let [path (seek #(and % (.exists (io/file %))) + (let [path (some (fn [p] + (when (and p (.exists (io/file p))) + p)) [path relative-path])] (assert (core/source-file? path)) ;; Prefix notation not supported in cljs.