Unit 4. Your first Clojure program

 

After completing this Unit, you will know how to write a real Clojure program that runs from the command line with some arguments and has a simple side effect: it prints some output to the console.

For that purpose, you will learn how to convert strings to data back and forth with str and read-string, and how to use the printing functions provided by Clojure. An interesting aspect of the printing functions is that they have both a side effects and a return value. The distinction between side effects and return value is a key idea of functional programming. We will explore this key idea in details in the context of the printing functions.

In the last Lesson of the Unit, you will learn how to store your Clojure code into source files, how to define the entry point of a Clojure program and how to run a Clojure program from the command line.

We will discuss the following topics:

  • Lesson 15 explains how to convert strings to data back and forth with str and read-string
  • Lesson 16 explores how to print to the console and explains the distinction between side effects and return values
  • Lesson 17 explores how to store code in source files and how to run a program from the command line