Reputation: 247
I have a couple of questions about Hello World in Clojure:
(println "Hello, world!")
(let [i (atom 0)]
(defn generate-unique-id
"Returns a distinct numeric ID for each call."
[]
(swap! i inc)))
Upvotes: 3
Views: 802
Reputation: 2519
println
is a built-in function in Clojure, and just happens to have the same name as in Java (check out the source). Some Java libraries are imported by default (java.io
and java.lang
I think).
The parentheses are syntax for calling a function and come from Lisp. For example, this function call in Java:
addTwoNumbers(4, 5);
would be written as follows in Clojure (and Lisp):
(addTwoNumbers 4 5)
Clojure's community is vibrant and growing. Check out the Google Group
Upvotes: 8