Hello world in Clojure
Firstly, Download & Install leiningen - which will help you build your Clojure project.
Create a new project using leiningen's lein command:
$ lein new hello-world
#Generating a project called hello-world based on the 'default' template.
#To see other templates (app, lein plugin, etc), try `lein help new`.
Edit the project.clj file that was created for you:
$ cd hello-world
$ nano project.clj
Overwrite the contents of project.clj with the following code
(defproject hello-world "0.1.0-SNAPSHOT"
:main hello-world.core
:dependencies [[org.clojure/clojure "1.5.1"]])
Next, edit the main source file of your project:
$ nano src/hello_world/core.clj
Overwrite the contents of src/helloworld/core.clj_ with the following code:
(ns hello-world.core)
(defn -main [& args]
(println "Hello, World!"))
You are now able to run your app:
$ lein run
# Hello, World!
What this gives you is a Clojure project that prints "Hello, World!" to the terminal - all that remains is to let your imagination take over.
What is next ??
Try out some of the Clojure code in the articles below by editing the src/hello_world/core.clj file and running $ lein run
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Clojure
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#