Clojure - 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. The number of parameters is the function’s arity. This chapter discusses some function definitions with different arities.

In the following example, the function demo is defined with multiple arguments for each function definition.

(defn demo [] (* 2 2))
(defn demo [x] (* 2 x))
(defn demo [x y] (* 2 x y))

In the above example, the first function definition is a 0-arity function, since it has 0 arguements, one-param is 1-arity, and two-params is 2-arity and so on.

clojure_functions.htm
Advertisements