Random utils, vector utilities.
Random utils, vector utilities.
(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.
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 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.
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.
(pairs coll)Partitions a vector into pairs.
Partitions a vector into pairs.
(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.
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 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.
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 coll)(shuffle coll rng)Like clojure.core/shuffle but makes use of custom random number generator.
Like clojure.core/shuffle but makes use of custom random number generator.
(split-at idx v)Splits vector at the given index.
Splits vector at the given index.
(swap v index-1 index-2)Swaps two elements of a vector.
Swaps two elements of a vector.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |