Get the latest tech news
Refactoring Clojure
Refactoring some Clojure code that implements an order-1 word-level Markov text generator.
After playing a bit with it in the REPL to get a feeling of what is going on and of the shape of the data structure involved, we can start thinking how to refactor. Now that we have a function able to process a single sentence, we can go back to markov-data and realize that we can use reduce again, this time passing to it process-sentence and splitting the input string text on the boundaries of the full stop character: We also use slightly longer variable names to increase readability and the idiomatic way to add to a vector:
Or read this on Hacker News