^

Lion in a what?

Digital Media, Organizational, and Personal Development

twitter linkedin github gtalk

Learn clojure in Y minutes - Types

The following is from Learn clojure in Y minutes.

The three object types used in Clojure are:

  1. booleans
  2. strings
  3. numbers

You can use the class function to inspect objects:

> (class 1)
java.lang.Long

> (class 1.)
java.lang.Double

> (class (""))
java.lang.String

> (class false)
java.lang.Boolean

> (class nil)
nil

To create a literal list of data:

> ’(+ 1 2)
(+ 1 2)

> (quote (+ (1 2)))
(+ 1 2)

The ' character prevents the form from being evaluated.

The opposite of ' is eval:

> (eval ‘(+ 1 2))
3