clojure Functions Defining Functions


Example

Functions are defined with five components:

The header, which includes the defn keyword, the name of the function.

(defn welcome ....)

An optional Docstring that explains and document what the function does.

(defn welcome 
    "Return a welcome message to the world"
     ...)

Parameters listed in brackets.

(defn welcome 
    "Return a welcome message"
    [name]
    ...)

The body, which describes the procedures the function carries out.

(defn welcome 
    "Return a welcome message"
    [name]
    (str "Hello, " name "!"))

Calling it:

=> (welcome "World")

"Hello, World!"