Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Learning functional/Clojure programming - practical exercises? [closed]

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.


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.


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


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.


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.