Giter VIP home page Giter VIP logo

clojure-koans's Introduction

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!

Getting Started

The easiest and fastest way to get the koans up and running is to download the latest zip file from Github. This way, you'll have all the dependencies you need, including Clojure itself and JLine, and you can skip the rest of this section (skip to "Running the Koans").

If you're starting from a cloned or forked repo, that's cool too. This way you'll be able to track your progress in Git, and see how your answers compare to others, by checking out the project's Network tab. You might want to create your own branch - that way if you pull back the latest koans from master, it'll be a bit easier to manage the inevitable conflicts if we make changes to exercises you've already completed.

The only things you'll need to run the Clojure Koans are:

clojure-1.3.0.jar needs to be in a directory lib under this project.

You can use Leiningen to 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).

After you have leiningen installed, run

lein deps

which will download all dependencies you need to run the Clojure koans.

Running the Koans

To run the koans, simply run

script/run on Mac/*nix

script\run on Windows

It's an auto-runner, so as you save your files with the correct answers, it will advance you to the next koan or file.

You'll see something like this:

Problem in  /home/colin/Projects/clojure-koans/src/koans/equalities.clj
---------------------
Assertion failed!
We shall contemplate truth by testing reality, via equality.
(= __ 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 might be easy (especially at first) to just fill in the blanks making things pass, you should work thoughtfully, making sure you understand why the answer is what it is. Enjoy your path to Clojure enlightenment!

Trying more things out

There's a REPL (Read-Evaluate-Print Loop) included in the Clojure Koans. Just run:

script/repl on Mac/*nix

script\repl on Windows

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 with CTRL-d on any OS.

Contributing

Patches are encouraged! Make sure the answer sheet still passes (script/test, or script\test on Windows), and send a pull request.

The file ideaboard.txt has lots of good ideas for new koans to start, or things to add to existing koans. So write some fun exercises, add your answers to resources/koans.clj, and we'll get them in there!

Feel free to contact me (Colin Jones / trptcolin) on Github or elsewhere if you have any questions or want more direction before you start pitching in.

Contributors

https://github.com/functional-koans/clojure-koans/contributors

Credits

These exercises were started by Aaron Bedra of Relevance, Inc. 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 without Relevance's initiative, this project would not exist.

Using the koans metaphor as a tool for learning a programming language started with the Ruby Koans by EdgeCase.

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.

clojure-koans's People

Contributors

abedra avatar alexrobbins avatar calebphillips avatar citizen428 avatar dsouth avatar ericlavigne avatar jaskirat avatar lukearno avatar mg50 avatar noamraph avatar slagyr avatar sritchie avatar trptcolin avatar verdammelt avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.