I would format it like this:
(ns phrase
(:require [clojure.string :as s]))
(defn word-array [phrase]
(s/split (s/lower-case phrase) #"\W+"))
(defn word-count [phrase]
(frequencies (word-array phrase)))
Notice that I included the require
statement as part of the ns
definition.
Whether or not you use threading macros (->
, ->>
) is generally a matter of personal preference, and there's nothing wrong with using them here, but I think in this case since you're only using 2 functions, I find the above easier to read. You might also consider using comp
:
(def word-array (comp #(s/split % #"\W+") s/lower-case)
(def word-count (comp frequencies word-array))