Values in Clojure
Clojure has various value types including strings, integers, floats, booleans, etc. Here are a few basic examples.
To run the program, save it as values.clj
and use the clojure
command:
In Clojure, we don’t need to explicitly declare a package or import statements like in some other languages. Instead, we define a namespace using ns
and can require other namespaces as needed.
Clojure uses prefix notation for arithmetic and logical operations. For example, (+ 1 1)
instead of 1 + 1
.
String concatenation in Clojure is typically done with the str
function, which can take any number of arguments.
Clojure’s printing function is simply println
, which automatically adds a newline after printing.
Boolean operations in Clojure are similar to other languages, using and
, or
, and not
.
This example demonstrates basic value types and operations in Clojure, providing a foundation for understanding the language’s syntax and functionality.