philipbohun.com

Glojure by Example: Values

Glojure has the usual Clojure values: strings, integers, ratios, floating-point numbers, booleans, nil, and characters. str builds a string. + and / are functions, written before their arguments.

(println (str "glo" "jure"))
(println "1 + 1 =" (+ 1 1))

Dividing two integers yields a ratio, not a truncated integer. Use a floating-point number when you want a float.

(println "7/3 =" (/ 7 3))
(println "7.0/3.0 =" (/ 7.0 3.0))

Booleans use the functions and, or, and not. nil is the absence of a value. A character literal is a backslash followed by the character.

(println (and true false))
(println (or true false))
(println (not true))
(println "nil?" (nil? nil))
(println (str \g \l \j))

Run the file.

$ glj values.glj
glojure
1 + 1 = 2
7/3 = 7/3
7.0/3.0 = 2.3333333333333335
false
true
false
nil? true
glj

Next example: Bindings.