Bookmark Topic Watch Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic