Patrick Stevens

I’ve been trying to learn Clojure (a LISP) through Exercism, a programming exercises tool.
It took me an hour to get Hello, World! up and running, so I thought I’d document how it’s done.
I’m using Leiningen on Mac OS 10.11.4.

The Installing Clojure page on Exercism details how to install Leiningen; that part is easy.
Installing exercism is likewise easy, so we run exercism fetch clojure hello-world.

The README helpfully tells us what Hello, World! is, and a specification for the answer.
How are we to come up with our answer?
lein gives access to a REPL we can use to write an answer, but there’s no indication of
where to put our files so that lein can see them.

Let’s run lein test to see what lein complains about.

Exception in thread "main" java.io.FileNotFoundException:
Could not locate hello_world__init.class or hello_world.clj on classpath.
Please check that namespaces with dashes use underscores in the Clojure file name.,
compiling:(hello_world_test.clj:1:1)

Exception in thread "main" java.io.FileNotFoundException:
Could not locate hello_world_test__init.class or hello_world_test.clj on classpath.

I think this might be a back-step, because beforehand it was at least finding the test file.
I get the same error if I navigate into the test folder and run lein test.
And if we try lein run, we get the original error:

Exception in thread "main" java.io.FileNotFoundException:
Could not locate hello_world__init.class or hello_world.clj on classpath.

The src/my_stuff/core.clj file corresponds to the my-stuff.core namespace.

That would imply that our source file corresponds to the hello-world.hello-world namespace.
Let’s try flattening out the structure a bit, and returning the hello_world_test.clj to where at least
lein recognised it: