Clojure "Game of Life"
Your code actually isn't terrible, but there are a few places where it can be improved.



First, the ref. It's entirely unnecessary in this case. What I'd change to keep everything immutable:

Change your declaration at the top to just:

(def initial-state [[false false false false false]
                    [false false true  false false]
                    [false false true  false false]
                    [false false true  false false]
                    [false false false false false]])


This now defines, as the name suggests, the initial state of the game. This will no longer be used to store the running state.

Now, you can change tick to get rid of the need for ref-set:

(defn tick [state times]
  (loop [i 0 ; Moved the counter into a loop
         acc-state state] ; Keeping track of the running state
   (when (&lt; i times)
     (println (str i ":"))
     (pretty-print acc-state)

     ; Recur into the loop instead of the function itself
     (recur (inc i) (next-state acc-state)))))

(defn -main [&amp; args]
  (tick initial-state 5))


Note how I just made the running state an accumulator of a loop. I think the whole design should be rethought though. Really, you could just get the successive states by using iterate, and take as many as you want. Lets say you want to get the first five states after the initial-state:

(take 5 (iterate next-state initial-state))


Now, your entire tick function can basically be written as:

; Obviously, change 5 to however many states you want to produce
(doseq [state (take 5 (iterate next-state initial-state))]
  (pretty-print state))




I would change pretty-print to a format style function that returns a string instead of printing directly. That way, the caller can make use of your prettying, but decide how/when they want to display it.



Your count-true-neighbors function is huge. I'd break it down into a few discreet parts:


You have a part that produces a list of neighbors to check
You have a part that does bounds checking


I'd change it to something more like:

(defn neighbors-of [x y]
  (for [p (range (- x 1) (+ x 2))
        q (range (- y 1) (+ y 2))
        :when (not (and (= x p) (= y q)))]
    [p q]))

(defn inbounds? [x y size]
  (and (&lt;= 0 x (dec size)) ; Comparison operators can be chained!
       (&lt;= 0 y (dec size))))

(defn count-true-neighbours [state x y]
  (let [size (count state)]
    (-&gt;&gt; (neighbors-of x y)
      (map (fn [[p q]] ; You can deconstruct here directly
             (when (inbounds? p q size)
               (get-state state p q))))
      (filter true?)
      (count))))


Your mapping function could be changed to:

(map (fn [[p q]]
       (and (inbounds? p q size)
            (get-state state p q))))


Although the benefit here is subjective. 

Things to note:


&lt;= and other comparison operators can be used to check more than two arguments! I'm making use of that in inbounds? to neaten it up a bit.
I reduced your bounds check in the map down to (when (inbounds? p q size) ...). when returns nil (falsey) if the condition fails, so you don't need to explicitly return false.




(or (= alive-neighbours 2) (= alive-neighbours 3)))


Can also be written as:

(#{2 3} alive-neighbors)


It's a matter of style which you prefer. I prefer the latter personally.



(nth (nth state y) x))


Can also be written as:

(get-in state [y x])    




There's a few things to note in pretty-print:

(reduce str strings)


Isn't wrong, but a more idiomatic way of writing it would be:

(apply str strings)


With:

(mapv #(if %1 "■ " "□ "))


You add explicit spaces after the display characters. It may be cleaner to use join to add the spaces. This limits the repetition, and gets rid of the trailing space. This also lets you just use the character literals directly.

And when you use threading macros (-&gt;&gt;), you put the expression being threaded on the next line. Personally, I prefer to put the threaded expression on the same line as the -&gt;&gt;. This makes it clearer what's being threaded.

Taking that all together, I'd write that whole bit as:

(-&gt;&gt; (nth state i)
     (mapv #(if %1 \■ \□))
     (s/join " ")
     (apply str)))


Where s is an alias for clojure.string.