Skip to content

Instantly share code, notes, and snippets.

@bbqbaron
Created September 17, 2019 02:33
Show Gist options
  • Save bbqbaron/a2f1353eb849dd0893391db9138990f9 to your computer and use it in GitHub Desktop.
Save bbqbaron/a2f1353eb849dd0893391db9138990f9 to your computer and use it in GitHub Desktop.
; this isn't to throw shade at the dev; i just felt java had a lot of incidental complexity and wanted to understand what the code does
(defn fragmentize-chunk [chunk]
(set (map #(take % chunk) [1 2 3])))
(defn fragmentize-word [word]
(->> (range (count word))
(map #(drop % word))
(mapcat fragmentize-chunk)
(map clojure.string/join)))
(defn fragmentize [words]
(->> words
(map clojure.string/lower-case)
(mapcat fragmentize-word)
frequencies))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment