Recently I’ve been spending some time learning Clojure and I’ve really been enjoying it. It took me a bit of time to understand functional programming and to begin to grasp how it would help me write better applications. I’m definitely a beginner when it comes to functional languages, but each day I feel that my grasp on it becomes firmer than the day before. I started by going through Stuart’s Programming Clojure book first and then, after making it through the basics there, I started looking at some open source libraries that solve problems that I’m already comfortable with in other languages (such as building web applications).
Yesterday I decided that the next step was to learn my way around the standard functions available in Clojure. I’ve decided to try something new (for me at least) to see if I can work my way through the standard functions rapidly: I’m writing a series of examples for each standard function, based initially on what is in the Clojure cheat sheet. Each example is written as a unit test using the build in clojure.test/is function. I’ll be pushing code up to a repo on Github as I make progress.
I’d love to hear if anyone else has used this technique for learning a standard library. What language did you use it with, did you publish your code and what were the drawbacks, if any? One of the reasons I feel that this is a useful exercise is because it is forcing me to actually write and practice Clojure. I’ve found out things about the language which I might not have otherwise discovered and I have many unanswered questions that I will either answer through further practice or through various Clojure community channels such as the Clojure Google Group or the Freenode #clojure IRC channel.
A few implementation details: I used the fantastically straight-forward Leiningen for generating the project, however I am not running the tests with it. For the tests I have set up a mapping in VIM:
nnoremap .c :!CLASSPATH=lib/* java clojure.main <CR>I haven’t yet done the dance to set up slime.vim but I am sure that time will come. For now I can just type .c while viewing any of the clj files in the repo and that file will execute.
