Getting Started

4Clojure challenges users to solve koan-style problems. This is a fancy way of saying you'll be asked to fill in the blanks. The "blanks" that you will be filling in are indicated by a double underscore: '__'. This is not part of the syntax of the language. Any code which makes the final form evaluate to 'true' will be considered a correct answer. Lets consider the first problem:
(= __ true)

Any of the following would be considered correct answers:

  • true
  • (= 1 1)
  • (nil? nil)

  • Some problems will expect you to fill-in-the-blanks with a function. Here is a problem which asks you to provide a function to double a number:
    (= (__ 2) 4)
    (= (__ 3) 6)
    (= (__ 11) 22)
    (= (__ 7) 14)

    Any of the following forms are valid solutions:

  • (fn double [x] (* 2 x))
  • (fn [x] (* 2 x))
  • #(* 2 %)
  • (partial * 2)

  • Some operations are prohibited for security reasons. For instance, you will not be able to use "def" or switch namespaces. In addition, some problems have special restrictions. For example, a function which is supposed to count the number of elements in a sequence will not be allowed to use the "count" function. Obviously, this would defeat the purpose. Any special restrictions will be listed on the problem page.

    Many of the easier problems on this site can be solved using only your browser. However at some point you will want to install Clojure, and use your favorite IDE or text editor to write your code. We prefer using Emacs, but it's totally a matter of personal preference. Writing all your code directly on the site has a disadvantage:

  • 4Clojure is not an IDE, and doesn't try to be

  • Check out the official Clojure help page for instructions on installation and getting started.

    You should now be ready to start solving problems. Happy coding!

    Need help with a problem?

    Do you need some hints or help in solving a problem? Visit the 4Clojure Google Group.