This week I spent some time trying to see if I could port my Project Euler solutions code written in C++ to Clojure with little success. I’m kinda excited that my little experience in J (array processing) can come back into use. On the other hand, I’m also missing J’s super useful implementations of handy number sequences, such as i.x and whatnot. One thing that’s bogging me down is that I keep forgetting that Clojure is functional, meaning that everything returns a value or should. Also, recursion being the only looping method is kind of frustrating, at least right now.
Here’s one that I successfully converted (Problem 1 – Find the sum of all the multiples of 3 or 5 below 1000):
(loop [sum 0 x 1000] (if (zero? x) sum (recur (if (zero? (* (mod x 5) (mod x 3))) (+ sum x) sum) (dec x))))
There must be a much more elegant way to do it but that’s what I came up with. Until I get to actual list/array processing, I guess.
As for Git, haven’t really done much with it. Did a bit of reading through the Git Community Books and various sites online, trying to learn the driving force behind Git. I don’t think it actually matters that it is GIT that we use, as long as we use some sort of VCS of some kind. Although staging might be interesting and might be an incentive to actually work under a VCS without fears of idiotic commits and pushes. Workflow-wise, us being so tiny, it won’t matter whether it is Git or SVN or CVS or BZR. Just need to remember to commit.