Make selections from different sources, using either weighted or non-weighted random selection, with optional repeatability using controlled seeds.
Make selections from different sources, using either weighted or non-weighted random selection, with optional repeatability using controlled seeds.
(random-selections sources)(random-selections seed sources)Takes a map of {source [item]}, and returns a lazy seq of {:source source :item item} with the items randomly selected from the lists.
Takes a map of {source [item]}, and returns a lazy seq of {:source
source :item item} with the items randomly selected from the lists.(remove-selector-source selector source)Takes a selector (as from weighted-selector) and removes the source.
Takes a selector (as from `weighted-selector`) and removes the source.
(weight-count selector)Returns a count of weighted items in selector.
Returns a count of weighted items in selector.
(weighted-select seed selector)Returns one item from selector based on weighted random
selection. The selector is either the return value of
weighted-selector or a map of {item weight}.
Returns one item from selector based on weighted random
selection. The selector is either the return value of
`weighted-selector` or a map of {item weight}.(weighted-select-iteration input)(weighted-select-iteration seed {:keys [sources weights] :as input})Does a single "iteration" of weighted list selection. Takes a of inputs with:
Returns a vector of selection and updated inputs, or nil if there are no more items.
[{:source source :item item} updated-inputs]
Does a single "iteration" of weighted list selection. Takes a of
inputs with:
* :sources map of {source list}
* :weights either a selector or map of {source weight}
Returns a vector of selection and updated inputs, or nil if there
are no more items.
[{:source source :item item} updated-inputs](weighted-selections source-weights source-lists)(weighted-selections seed source-weights source-lists)Returns a lazy seq of items weighted random selected from sources. Takes a map of {source weight} and a map of {source [item]}. Each returned item will be a map of
Returns a lazy seq of items weighted random selected from
sources. Takes a map of {source weight} and a map of
{source [item]}. Each returned item will be a map of
* :source
* :item(weighted-selector weights)Creates a weighted random selector from a map of {source weight}. Call
weighted-select on the result.
Creates a weighted random selector from a map of {source weight}. Call
`weighted-select` on the result.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 |