What is form in Clojure?
In Clojure, a form is a piece of code that can be evaluated. Forms can be simple expressions, such as numbers or symbols, or they can be more complex structures, such as lists or maps.
For example, the following are all forms in Clojure:
-
42
(a number) -
"hello"
(a string) -
:keyword
(a keyword) -
'symbol
(a symbol) -
(+ 1 2 3)
(a list containing the symbol + and three numbers) -
{:a 1 :b 2}
(a map with two keys and values)
Forms are the building blocks of Clojure programs, and they can be combined in various ways to create more complex programs.