2010-10-29 15:41:20 +00:00
|
|
|
# Clojure Koans
|
|
|
|
|
|
|
|
The Clojure Koans are a fun and easy way to get started with Clojure - no
|
|
|
|
experience assumed or required. Just follow the instructions below to start
|
|
|
|
making tests pass!
|
2010-01-15 01:13:17 +00:00
|
|
|
|
2010-05-27 18:22:26 +00:00
|
|
|
|
2010-01-15 01:13:17 +00:00
|
|
|
### Getting Started
|
|
|
|
|
2010-05-27 01:16:28 +00:00
|
|
|
The only things you need to run the Clojure Koans are:
|
|
|
|
|
|
|
|
- JRE 1.5 or higher
|
2010-10-29 15:07:11 +00:00
|
|
|
- clojure-1.3.0-alpha1.jar
|
2010-05-27 18:22:26 +00:00
|
|
|
|
2010-10-29 15:07:11 +00:00
|
|
|
clojure-1.3.0-alpha1.jar needs to be placed in a directory `lib` under this
|
|
|
|
project.
|
2010-05-27 01:16:28 +00:00
|
|
|
|
2010-10-29 15:07:11 +00:00
|
|
|
You can use Leiningen (http://github.com/technomancy/leiningen) to
|
2010-11-02 00:50:05 +00:00
|
|
|
automatically install the Clojure jar in the right place. Leiningen will also
|
|
|
|
get you a couple more jarfiles, including JLine, which allows you some of the
|
|
|
|
functionality of readline (command-line history, for example).
|
2010-05-27 01:16:28 +00:00
|
|
|
|
2010-05-27 18:22:26 +00:00
|
|
|
After you have leiningen installed, run
|
2010-01-15 01:13:17 +00:00
|
|
|
|
|
|
|
`lein deps`
|
|
|
|
|
2010-11-01 18:13:48 +00:00
|
|
|
which will download all dependencies you need to run the Clojure koans.
|
2010-01-15 01:13:17 +00:00
|
|
|
|
2010-05-27 18:22:26 +00:00
|
|
|
|
2010-01-15 01:13:17 +00:00
|
|
|
### Running The Koans
|
|
|
|
|
|
|
|
To run the koans, simply run
|
|
|
|
|
2010-11-02 01:09:15 +00:00
|
|
|
`script/run` on Mac/\*nix
|
2010-05-27 01:16:28 +00:00
|
|
|
|
2010-11-02 01:09:15 +00:00
|
|
|
`script\run` on Windows
|
2010-10-29 15:07:11 +00:00
|
|
|
|
2010-11-01 18:13:48 +00:00
|
|
|
You'll see something like this:
|
|
|
|
|
|
|
|
FAIL in clojure.lang.PersistentList$EmptyList@1 (equalities.clj:1)
|
|
|
|
We shall contemplate truth by testing reality, via equality.
|
|
|
|
expected: (= __ true)
|
|
|
|
actual: (not (= nil true))
|
|
|
|
|
|
|
|
The output is telling you that you have a failing test in equalities.clj.
|
|
|
|
So open that file up and make it pass! In general, you just fill in the
|
|
|
|
blanks to make tests pass. Sometimes there are several (or even an infinite
|
|
|
|
number) of correct answers: any of them will work in these cases.
|
|
|
|
|
|
|
|
The koans differ from normal TDD in that the tests are already written for you,
|
|
|
|
so you'll have to pay close attention to the failure messages, because up until
|
|
|
|
the very end, making a test pass just means that the next failure message comes
|
|
|
|
up.
|
|
|
|
|
|
|
|
While it's very easy (especially at first) to just fill in the blanks making
|
|
|
|
things pass, you should work slowly, making sure you understand why the answer
|
|
|
|
is what it is. Enjoy your path to Clojure enlightenment!
|
2010-10-29 15:41:20 +00:00
|
|
|
|
2010-10-29 15:43:32 +00:00
|
|
|
|
|
|
|
### Contributing
|
|
|
|
|
|
|
|
Patches are encouraged! Make sure the answer sheet still passes (`test.sh`, or
|
|
|
|
`test.bat` on Windows), and send a pull request.
|
|
|
|
|
|
|
|
The file ideaboard.txt has lots of good places to start
|
|
|
|
|
|
|
|
|
2010-10-29 15:41:20 +00:00
|
|
|
### Contributors (in order of appearance)
|
|
|
|
|
|
|
|
- Aaron Bedra
|
|
|
|
- Colin Jones
|
|
|
|
- Eric Lavigne
|
|
|
|
- Nuno Marquez
|
|
|
|
|
|
|
|
|
|
|
|
### Credits
|
|
|
|
|
|
|
|
These exercises were started by [Aaron Bedra](http://github.com/abedra) of
|
|
|
|
[Relevance, Inc.](http://github.com/relevance) in early 2010, as a learning
|
|
|
|
tool for newcomers to functional programming. Aaron's macro-fu makes these
|
|
|
|
koans extremely simple and fun to use, and to improve upon, and Relevance's
|
|
|
|
initiative
|
|
|
|
|
|
|
|
Using the [koans](http://en.wikipedia.org/wiki/koan) metaphor as a tool for
|
|
|
|
learning a programming language started with the
|
|
|
|
[Ruby Koans](http://rubykoans.com) by [EdgeCase](http://github.com/edgecase).
|
|
|
|
|
2010-11-01 18:27:48 +00:00
|
|
|
|
|
|
|
### License
|
|
|
|
|
|
|
|
The use and distribution terms for this software are covered by the
|
|
|
|
Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
|
|
|
which can be found in the file epl-v10.html at the root of this distribution.
|
|
|
|
By using this software in any fashion, you are agreeing to be bound by
|
|
|
|
the terms of this license.
|
|
|
|
|