1 minute read

Code kata

From today, I will practice one programming kata per day and post the content here. Here goes the first one: My friend John likes to go to the cinema. He can choose between system A and system B. System A : buy a ticket (15 dollars) every time System B : buy a card (500 dollars) and every time buy a ticket the price of which is 0.

1 minute read

One awkwardness I haven’t really get rid of when using Clojure is for loops. Especially nested for loops that modifies some global variables. I find some solutions online where people use nested recursion or atoms, but can we just use one level of recursion? Let’s try out with a coding kata. Problem: Given an array of numbers, find the biggest sum of any two numbers. The same item in array cannot be used twice.

3 minute read

I have been working on some Clojure project at work for several months now, one little thing bothers me now and then is that it doesn’t allow dependency cycle in project. For example if a.clj requires b.clj, b.clj requires c.clj, then c.clj cannot require a.clj, in other words, c.clj cannot use anything inside a.clj. At first, I thought this is a bit odd, java doesn’t have that. And once in a while we have to solve such problems by creating a new namespace and move the common function into it.