- Notifications
You must be signed in to change notification settings - Fork2.1k
A set of exercises for learning Clojure
functional-koans/clojure-koans
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
The Clojure Koans are a fun and easy way to get started with Clojure - noexperience assumed or required. Just follow the instructions below to startmaking tests pass!
The easiest and fastest way to get the koans up and running is todownload thelatest zip file from Github.This way, you'll have all the dependencies you need, including Clojure itselfand JLine, and you can skip the rest of this section (skip to "Running theKoans").
If you're starting from a cloned or forked repo, that's cool too. This wayyou'll be able to track your progress in Git, and see how your answers compareto others, by checking out the project's Network tab. You might want to createyour own branch - that way if you pull back the latest koans from master, it'llbe a bit easier to manage the inevitable conflicts if we make changes toexercises you've already completed.
The only things you'll need to run the Clojure Koans are:
- JRE 1.5 or higher
- clojure-1.5.1.jar
You can useLeiningen toautomatically install the Clojure jar in the right place. Leiningen will alsoget you a couple more jarfiles, including JLine, which allows you some of thefunctionality of readline (command-line history, for example).
Dependencies are installed automatically with lein 2, but if for some reasonyou're on lein 1 and can't upgrade, you'll need to run
lein deps
which will download all dependencies you need to run the Clojure koans.
I strongly recommend that you upgrade to lein 2 instead!
If you're running from the zipfile, simply run
script/run on Mac/*nix
script\run on Windows
If you're running from a checkout using lein 2, run the koans via
lein koan run
It's an auto-runner, so as you save your files with the correct answers, it willadvance you to the next koan or file (conveniently, all files are prefixed withthe sequence that you should follow).
You'll see something like this:
Now meditate on /home/colin/Projects/clojure-koans/src/koans/01_equalities.clj:3---------------------Assertion failed!We shall contemplate truth by testing reality, via equality.(= __ true)The output is telling you that you have a failing test in the file named01_equalities.clj, on line 3. So you just need to open that file up and makeit pass! You'll always be filling in the blanks to make tests pass.Sometimes there could be several correct answers (or even an infinite number):any of them will work in these cases. Some tests will pass even if you replacethe blanks with whitespace (or nothing) instead of the expected answer. Make sureyou give one correct expression to replace each blank.
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 untilthe very end, making a test pass just means that the next failure message comesup.
While it might be easy (especially at first) to just fill in the blanks makingthings pass, you should work thoughtfully, making sure you understand why theanswer is what it is. Enjoy your path to Clojure enlightenment!
There's a REPL (Read-Evaluate-Print Loop) included in the Clojure Koans. Justrun:
script/repl on Mac/*nix
script\repl on Windows
If you're on lein 2,lein repl is what you want instead.
Here are some interesting commands you might try, once you're in a running REPL:
(find-doc"vec")(find-doc#"vec$")(doc vec)
And if those still don't make sense:
(doc doc)(doc find-doc)
will show you what those commands mean.
You can exit the REPL withCTRL-d on any OS.
Patches are encouraged! Make sure the answer sheet still passes(lein koan test), and send a pull request.
The file ideaboard.txt has lots of good ideas for new koans to start, or thingsto add to existing koans. So write some fun exercises, add your answers toresources/koans.clj, and we'll get them in there!
Please follow the guidelines inhttp://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html forcommmit messages, and put your code in a feature branch (not master) beforemaking the pull request. This makes patches easier to review.
Feel free to contact me (Colin Jones / trptcolin) on Github or elsewhere if youhave any questions or want more direction before you start pitching in.
https://github.com/functional-koans/clojure-koans/contributors
These exercises were started byAaron Bedra ofRelevance, Inc. in early 2010, as a learningtool for newcomers to functional programming. Aaron's macro-fu makes thesekoans extremely simple and fun to use, and to improve upon, and withoutRelevance's initiative, this project would not exist.
Using thekoans metaphor as a tool forlearning a programming language started with theRuby Koans byEdgeCase.
The use and distribution terms for this software are covered by theEclipse 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 bythe terms of this license.
About
A set of exercises for learning Clojure
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.