Tuesday, July 8, 2014

Exercism: "Space Age in Clojure"

This is my solution to the Space Age problem in Clojure.

In the first working iteration I made all "on-planet" functions use the on-earth function.
I also used let forms to avoid magic numbers.
It has a lot of duplication:

In the next iteration I played with comp and partial to write the make-on-planet-function factory that can create "on-planet" functions as compositions of the on-earth function:

Finally for the last version, I wrote a somehow more readable version of make-on-planet-function:

You can nitpick my solution here or see all the exercises I've done so far in this repository.

No comments:

Post a Comment