sequence>hashtable ( seq map-quot insert-quot -- hashtable )
Statistics > Computing histograms
Prev: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
hashtablea hashtable


Word description
Iterates over a sequence, allowing elements of the sequence to be added to a newly created hashtable. 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
! Count the number of times an element occurs in a sequence USING: assocs kernel prettyprint math.statistics ; "aaabc" [ ] [ inc-at ] sequence>hashtable .
H{ { 97 3 } { 98 1 } { 99 1 } }


Definition
IN: math.statistics

: sequence>hashtable
( seq map-quot insert-quot -- hashtable )
H{ } sequence>assoc ; inline