Thursday, June 26, 2014

Exercism: "Word count in Clojure"

This is my solution to the Word count problem in Clojure:

I created some local helpers and played with partial and comp to make the code more readable.
I also reduced the number of parameters of some local helpers by using some free variables.

I really liked how the reduce function can be applied to a map data-structure in Clojure.

You can nitpick my code here.



After learning some new stuff, I've been able to simplify the code a bit more:

I used the frequencies function to count each word frequency and the defn- special macro to make extract-words-from function private.

You can nitpick this new version here.

No comments:

Post a Comment