3 ms·
Here's what I meant: (def nouns #{"apple" "book" "house"}) (def text "My apple is red.") (defn noun? "intersect word with nouns and see if w
by danneu 14y ago
Here's what I meant:
(def nouns #{"apple" "book" "house"})
(def text "My apple is red.")
(defn noun?
"intersect word with nouns and see if we've got anything."
[word]
(not-empty (intersection (set [word]) nouns)))
(defn nurblize
[text]
(let [words (split text #" ")]
(map #(if (noun? %) "nurble" %) words)))
(nurblize text) ;=> ("My" "nurble" "is" "red")
- adambard 14y agoYeah, that's much better than mine.
- deleted 14y ago[deleted]