Clojure
Notes on Clojure.
Reference
Concatenating strings
require '[clojure.string :as string])
(
"foo" "bar"]) (string/join [
List files recursively
Clojure
To list files recursively in Clojure1
file-seq "/etc") (
Babashka
If using Babashka, the following works:
file-seq (clojure.java.io/file "/etc")) (
filter #(.endsWith (.toString %) ".conf")
(file-seq "/etc")) (
Get home directory
def home (System/getProperty "user.home")) (
Filter collection
Use the syntax (filter predicate collection)
. For instance, to filter a collection of strings that end with bar
, do:
def strings ["Foobar" "Barfoo" "Foobaz" "Barbar"])
(
filter
(fn [s] (clojure.string/ends-with? s "bar")) strings) (