Liking cljdoc? Tell your friends :D

com.michaelgaare.clj-util.random.selection

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.
raw docstring

random-selectionsclj

(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.
raw docstring

remove-selector-sourceclj

(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.
raw docstring

weight-countclj

(weight-count selector)

Returns a count of weighted items in selector.

Returns a count of weighted items in selector.
raw docstring

weighted-selectclj

(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}.
raw docstring

weighted-select-iterationclj

(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:

  • :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]

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]
raw docstring

weighted-selectionsclj

(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

  • :source
  • :item
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
raw docstring

weighted-selectorclj

(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.
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close