views:

275

answers:

4

I'm learning functional programming with Clojure. What practical excersises 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).

+4  A: 

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

sepp2k
+6  A: 

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.

Michiel Borkent
+3  A: 

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.

j-g-faustus
+1  A: 

You might find this page useful as well - 15 Exercises for Learning a new Programming Language.

Bozhidar Batsov