Immutable values

Fixme work in progress

Values in Clojure include numbers, characters and strings. When you use functions on these values they do not change, instead a new value is returned.

Lets look at a simple example with a number:

  1. (def two-little-ducks 22)
  2. (inc two-little-ducks)
  3. ;; => 23
  4. two-little-ducks
  5. ;; => 22

Another example with a string:

  1. (def message "Strings are immutable")
  2. (str message "," " " "you cant change them")
  3. ;; => "Strings are immutable, you cant change them"
  4. message
  5. ;; => "Strings are immutable"

Fixme Add an exercise