call function in clojure
To call a function in Clojure, you can use the syntax (function-name arguments)
. Here's an example:
(defn add [a b]
(+ a b))
(add 2 3) ; calling the add function with arguments 2 and 3
In this example, we define a function called add
that takes two arguments a
and b
and returns their sum. To call the add
function, we use (add 2 3)
which will evaluate to 5
.
You can also call built-in functions in Clojure, such as println
, which is used to print output to the console. Here's an example:
(println "Hello, world!")
This will print the string "Hello, world!" to the console when the code is executed.