This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-07-02
Channels
- # admin-announcements (11)
- # beginners (183)
- # boot (139)
- # cider (37)
- # clojure (134)
- # clojure-germany (23)
- # clojure-italy (28)
- # clojure-japan (24)
- # clojure-russia (12)
- # clojurebridge (17)
- # clojurescript (222)
- # code-reviews (6)
- # core-async (9)
- # core-matrix (4)
- # datomic (13)
- # editors (2)
- # euroclojure (13)
- # ldnclj (69)
- # off-topic (32)
- # om (3)
- # onyx (24)
- # reagent (10)
- # yada (31)
Hi, I just hacked something together to find out if any string from a file given a list of strings, is contained in any .java file in a folder: https://gist.github.com/sveri/701aa9f1cd1af12a37d7 As much as this solution works, as much I don't like it. Any other ideas on how to approach that? PS: an example is in the bottom of the gist
@sveri, line 15 could take advantage of the alias io
. I was expecting to see another re-matches
for search-string-in-file
. I am wondering if the shape of search-package-in-source
could use (--> ... )
leading up to a filter
at the end. Clean and easy to read.
@sveri #(= nil %)
could just be nil?
, but even better (remove #(= nil %) (map #(search-string-in-file % file) libs)))
to (remove #(search-string-in-file % file) libs)
..
and (if (and needle haystack (.contains (.toLowerCase haystack) (.toLowerCase needle))) fp nil)
could be replaced just with that condition, just need a truthy return
and the (reduce (fn [a b] (conj a b)) [] ...))
patterns could be (into [] …)
i believe
search-string-in-file
is also slurping the file for each search term, might want to memoize or capture that in a closure (curry search-string-in-file
to take the file first, this also lets #(search-string-in-file % file)
get unwrapped to (search-string-in-file file)