Why Not a Function #30: id

(import '(java.util UUID))

(defn id ([] (id 0)) ([n] (UUID. 1 n)))

id is a very simple function useful for creating UUIDs in tests. We can pass a number which will be used for the minor bits.

(id)
=> #uuid"00000000-0000-0001-0000-000000000000"

(id 1)
=> #uuid"00000000-0000-0001-0000-000000000001"
Written on April 23, 2020