collection

List of symbols:

clear!, empty?, flatten, in?, not-empty?, reverse

clear!

Usage: (clear! container)

Clears a container (vector, hash-map, string). This is destructive!

Example:

(def test-clear-vec (vec 1 2 3))
(test::assert-false (empty? test-clear-vec))
(clear! test-clear-vec)
(test::assert-true (empty? test-clear-vec))

empty?

Usage: (empty? v)

Usage (empty? s)

No Examples

flatten

Usage: (flatten & rest)

Takes a sequence composed of individual values or sequences of values and turns it into one vector of values.

Example:

(test::assert-equal [1 2 3 1 2 3] (flatten 1 2 3 (list 1 2 3)))
(test::assert-equal [1 2 3 1 2 3] (flatten 1 2 3 [1 2 3]))
(test::assert-equal [1 2 3 1 2] (flatten 1 2 3 (list 1 2)))
(test::assert-equal [1 2 3 1 2 3 1 2] (flatten 1 2 3 (list 1 2 3 (list 1 2))))

in?

Usage: (in? needle haystack)

In provided sequence, haystack, find a specific value, needle.

Example:

(test::assert-true (in? [1 2 3 4 5] 3))
(test::assert-false (in? [1 2 3 4 5] 9))
(test::assert-true (in? (list 1 2 3 4 5) 3))
(test::assert-true (in? '(1 2 3 4 5) 5))

not-empty?

Usage: (not-empty? v)

Usage (not-empty? s)

No Examples

reverse

Usage: (reverse items)

Produce a vector that is the reverse of items.

Example:

(let (tmap [1 2 3 0])
(test::assert-false (empty? tmap))
(set! tmap (reverse tmap))
(test::assert-equal 2 (get tmap 2))
(test::assert-equal 1 (get tmap 3))
(test::assert-equal 0 (get tmap 0))
(test::assert-error (reverse "string")))