Wednesday, July 8, 2015

Exercism: "Difference Of Squares in Clojure"

I solved the Difference Of Squares problem in Clojure.

This exercise was very easy.

I played with partial and the thread last macro (->>) to try to make the solution more readable:

It turns out that I had done this exercise before.
You can see that version in Euler Project: Problem 6 in Clojure

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

Sunday, July 5, 2015

Exercism: "Binary Search Tree in Clojure"

I solved the Binary Search Tree problem in Clojure.

I wrote three versions of the to-list function which makes a depth-first traversal of the tree returning the sequence of visited values.

This is my first version:

This is the second one using concat:

And the last one using the tree-seq function that I discovered looking at other solutions in Exercism: You can nitpick my solutions here and/or see all the exercises I've done so far in this repository.

Saturday, July 4, 2015

Exercism: "Accumulate in Clojure"

I solved the Accummulate problem in Clojure.

This is an easy one in Clojure, the only restriction is that you can't use map.

I did 3 versions to practice:

A recursive one:

Another one using reduce:

And another one using a sequence comprehension: You can nitpick the solutions here and/or see all the exercises I've done so far in this repository.