Using and defining functions
In this recipe, we will review Clojure's function definitions:
- Defining simple functions
- Defining variadic functions
- Defining multiple arity functions
- Defining functions that specify arguments using a keyword
- Defining functions with a pre-condition and a post-condition
You only need REPL, as described in the first recipe in this chapter, and no additional libraries. Start REPL so that you can test the sample code immediately in this recipe.
How to do it...
Here, we will learn how to define functions using Clojure. Let's start with a simple function which returns
Defining simple functions
Let's start with a minimum function definition. Here is a minimal syntax of
(defn funtion-name [arg1 arg2 ...] ...