Win a copy of Design for the Mind this week in the Design forum!
    Bookmark Topic Watch Topic
 
friki data migration
Ranch Hand
Posts: 772
  • Mark post as helpful
  • send pies
  • Report post to moderator
Clojure is -like Scala- a functional dialect of Java, but its basic syntax is closer to Scheme. You can get it at http://clojure.org/. Once you have extracted the jar file, start the interpreter with



and you're ready to evaluate stuff:



Code that's saved in files can be loaded by something like



Clojure question can be asked in the Incubator > Clojure forum here at JavaRanch, and there are more interesting links at BeClojurian.


An example

To start with, here's a short Clojure program that solves the first problem of Project Euler : If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.

[code=java](defn divisible-by-3-or-5 [n]
 
    Bookmark Topic Watch Topic
  • New Topic