Fork me on GitHub
Idan Melamed10:01:09 After a couple of years of trying to stick with learning Clojure, I created a tic-tac-toe "game engine". Any feedback would be appreciated. 🙂


One thing I noticed is that your docstrings should be before the function parameters. Anything after the function parameters is evaluated, so each function is actually initializing the string the immediately forgetting about it

thanks3 3
👍 3

in draw-status you can use when instead of if


A style I prefer is to destructure right in the parameters.. i.e. instead of

(defn f [foo]
  (let [{:keys [a b]} foo] ...))
you could just do:
(defn f [{:keys [a b]}] ...)


Instead of This is the only function that should be used from outside this namespace..., you can use defn- to make fns private to the namespace.


Also even though this is a pretty contained project and you don't have a lot to gain, on top of replacing most defns with defn- (or instead of it) you can have a separate api namespace just for symbols that are meant to be exposed to the world


I'd also add some specs and try to use them to validate the user's input (e.g. move) to find out if/how I could "reduce" the boilerplate in the turn function