Using Functions

Function calls in Clojure look very similar to those in other languages. Let’s look at calling a function in Python and in Clojure:

 
functionName(param1, param2)
 
 
(function-name param1 param2)

The main difference is that the function name comes after the paren in the Clojure version. This is because a function call is simply a list containing the function name and its parameters. A list is a special data structure in Clojure because the compiler expects the first argument in lists to be callable. If you wanted to create a list data structure, you’d call the list function.

 
(​list​ 1 2 3)

Get Web Development with Clojure now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.