sequence>assoc ( seq map-quot insert-quot exemplar -- assoc )
Statistics > Computing histograms
Prev:sorted-histogram ( seq -- alist )
Next:sequence>assoc! ( assoc seq map-quot: ( x -- ..y ) insert-quot: ( ..y assoc -- ) -- assoc )


Vocabulary
math.statistics

Inputs and outputs
seqa sequence
map-quota $quotation
insert-quota quotation
exemplaran exemplar assoc
assocan assoc


Word description
Iterates over a sequence, allowing elements of the sequence to be added to a newly created assoc. The map-quot gets passed each element from the sequence. Its outputs are passed along with the assoc being constructed to the insert-quot, which can modify the assoc in response.

Examples
! Iterate over a sequence and increment the count at each element ! The first quotation has stack effect ( key -- key ), a no-op USING: assocs prettyprint kernel math.statistics ; "aaabc" [ ] [ inc-at ] H{ } sequence>assoc .
H{ { 97 3 } { 98 1 } { 99 1 } }


Definition
USING: kernel math.statistics.private ;

IN: math.statistics

: sequence>assoc
( seq map-quot insert-quot exemplar -- assoc )
clone (sequence>assoc) ; inline