Learning functional/Clojure programming - practical exercises?

12,226

Solution 1

I would recommend doing the Project Euler exercises:

http://projecteuler.net/

Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.

Because many programmers are solving Project Euler exercises, you can compare the solutions to other (non-functional) programming languages, but also Clojure solutions are available: http://clojure-euler.wikispaces.com/, so you can contrast imperative vs. functional/idiomatic Clojure.

Of course you will learn the most by first doing the exercises yourself, without consulting any of the solutions.

Solution 2

4clojure was launched recently. It takes a lot of inspiration from Functional Koans, and several of the puzzles from 99 Lisp Problems; but it improves on both by providing a learning experience for which you need only your browser.

Problems vary in difficulty from language tutorials like What is the second element of this list? to thought-provoking questions like Is it possible to arrange these N words so that each differs from the preceding one by at most one character, and more problems are being added every day.

Solution 3

Try 99 Lisp Problems. The solutions aren't in clojure, but it should be easy to translate.

Solution 4

I recently started learning Clojure myself, and found labrepl useful.

It lets you get familiar with the basics and the REPL, contains a number of exercises and describes quite a bit of non-obvious stuff that is hard to find in the documentation since you don't yet know what you are looking for.

Recommended.

Edit

Also the Python Challenge, a series of puzzles that can be solved by a few lines of programming; the solution to a puzzle gives you the URL to visit for the next puzzle.

Although not specifically Clojure, the puzzles are quite entertaining and a good way to get your feet wet with any new language IMHO. (There are a couple of puzzles that are specific to Python, but the majority are not. See the forum for Python Challenge Hints when stuck.)

The Python Challenge differs from the Euler tasks in being more practical and less math oriented; tasks include things like filtering the bytes of an image and following hyperlinks programmatically.

Solution 5

There are some Functional Koans for Clojure: https://github.com/functional-koans/clojure-koans

I have not gotten round to trying these, but have heard good reviews.

Share:
12,226
Konrad Garus
Author by

Konrad Garus

Quality nut. So disappointed with "good enough" and "I don't care I'm too busy chasing my tail".

Updated on June 11, 2022

Comments

  • Konrad Garus
    Konrad Garus almost 2 years

    I'm learning functional programming with Clojure. What practical exercises can you recommend? Online repositories with solutions would be perfect.

    One idea I can think of is going through all the popular algorithms on sorting, trees, graphs etc. and implementing them in Clojure myself. While it could work, it may be pretty steep and I'm likely to do it inefficiently (compared to someone who knows what she's doing).

  • shivaniaakanksha
    shivaniaakanksha about 13 years
    This article describes how to get started with koans for three languages including clojure: sett.ociweb.com/sett/settJan2011.html#clojure-koans
  • rcbevans
    rcbevans over 9 years
    The site clojure-euler.wikispaces.com is no longer available as the wiki has expired