Clojure - Functions



Clojure is known as a functional programming language, hence you would expect to see a lot of emphasis on how functions work in Clojure. This chapter covers what all can be done with functions in Clojure.

Sr.No. Functions & Description
1 Defining a Function

A function is defined by using the ‘defn’ macro.

2 Anonymous Functions

An anonymous function is a function which has no name associated with it.

3 Functions with Multiple Arguments

Clojure functions can be defined with zero or more parameters. The values you pass to functions are called arguments, and the arguments can be of any type.

4 Variadic Functions

Clojure offers the ‘case’ statement which is similar to the ‘switch’ statement available in the Java programming language.

5 Higher Order Functions

Higher-order functions (HOFs) are functions that take other functions as arguments. HOFs are an important functional programming technique and are quite commonly used in Clojure.

Advertisements