io.randomseed.utils.vec
added in 1.0.0
Random utils, vector utilities.
get-rand-nth
added in 1.0.0
(get-rand-nth v)
(get-rand-nth v rng)
Returns a random element of the given vector. When the second argument is present it should be an instance of random number generator used to get the random position.
of-strings
(of-strings coll)
(of-strings coll skip-if)
Ensures that the given collection or a single value is a non-empty vector of strings. Optional function can be given to skip matching input argument and leave it as is.
rand-nths
(rand-nths coll)
(rand-nths coll num)
(rand-nths coll num rng)
Returns a vector with the given number of randomly selected elements of the given vector. No element will be selected more than once.
replace-by-last
(replace-by-last v index)
Removes an element under the given index from a vector by replacing it with the last one. For the last element index it simply removes it.
shuffle
(shuffle coll)
(shuffle coll rng)
Like clojure.core/shuffle but makes use of custom random number generator.