philipbohun.com

Glojure by Example: Lists

Lists are linked sequences that grow at the front. A quoted list is data. Without the quote, Glojure would try to call 10 as a function. Code itself is made of lists: the first element is the operation.

(def nums '(10 20 30))
(println nums)
(println (first nums))
(println (rest nums))
(println (conj nums 5))
(println (cons 0 '(1 2)))

conj on a list puts the new element first.

$ glj lists.glj
(10 20 30)
10
(20 30)
(5 10 20 30)
(0 1 2)

Next example: Maps.