math.statistics: rename histogram* to histogram! and rename sequence>assoc* to sequence>assoc!

db4
Slava Pestov 2010-02-03 20:28:20 +13:00
parent 662eba7a67
commit 87665c8f40
2 changed files with 9 additions and 9 deletions

View File

@ -84,7 +84,7 @@ HELP: histogram
} }
{ $description "Returns a hashtable where the keys are the elements of the sequence and the values are the number of times they appeared in that sequence." } ; { $description "Returns a hashtable where the keys are the elements of the sequence and the values are the number of times they appeared in that sequence." } ;
HELP: histogram* HELP: histogram!
{ $values { $values
{ "hashtable" hashtable } { "seq" sequence } { "hashtable" hashtable } { "seq" sequence }
{ "hashtable" hashtable } { "hashtable" hashtable }
@ -92,7 +92,7 @@ HELP: histogram*
{ $examples { $examples
{ $example "! Count the number of times the elements of two sequences appear." { $example "! Count the number of times the elements of two sequences appear."
"USING: prettyprint math.statistics ;" "USING: prettyprint math.statistics ;"
"\"aaabc\" histogram \"aaaaaabc\" histogram* ." "\"aaabc\" histogram \"aaaaaabc\" histogram! ."
"H{ { 97 9 } { 98 2 } { 99 2 } }" "H{ { 97 9 } { 98 2 } { 99 2 } }"
} }
} }
@ -125,7 +125,7 @@ HELP: sequence>assoc
} }
{ $description "Iterates over a sequence, allowing elements of the sequence to be added to a newly created " { $snippet "assoc" } " according to the passed quotation." } ; { $description "Iterates over a sequence, allowing elements of the sequence to be added to a newly created " { $snippet "assoc" } " according to the passed quotation." } ;
HELP: sequence>assoc* HELP: sequence>assoc!
{ $values { $values
{ "assoc" assoc } { "seq" sequence } { "quot" quotation } { "assoc" assoc } { "seq" sequence } { "quot" quotation }
{ "assoc" assoc } { "assoc" assoc }
@ -133,7 +133,7 @@ HELP: sequence>assoc*
{ $examples { $examples
{ $example "! Iterate over a sequence and add the counts to an existing assoc" { $example "! Iterate over a sequence and add the counts to an existing assoc"
"USING: assocs prettyprint math.statistics kernel ;" "USING: assocs prettyprint math.statistics kernel ;"
"H{ { 97 2 } { 98 1 } } clone \"aaabc\" [ inc-at ] sequence>assoc* ." "H{ { 97 2 } { 98 1 } } clone \"aaabc\" [ inc-at ] sequence>assoc! ."
"H{ { 97 5 } { 98 2 } { 99 1 } }" "H{ { 97 5 } { 98 2 } { 99 1 } }"
} }
} }
@ -157,13 +157,13 @@ ARTICLE: "histogram" "Computing histograms"
"Counting elements in a sequence:" "Counting elements in a sequence:"
{ $subsections { $subsections
histogram histogram
histogram* histogram!
sorted-histogram sorted-histogram
} }
"Combinators for implementing histogram:" "Combinators for implementing histogram:"
{ $subsections { $subsections
sequence>assoc sequence>assoc
sequence>assoc* sequence>assoc!
sequence>hashtable sequence>hashtable
} ; } ;

View File

@ -64,7 +64,7 @@ IN: math.statistics
PRIVATE> PRIVATE>
: sequence>assoc* ( assoc seq quot: ( obj assoc -- ) -- assoc ) : sequence>assoc! ( assoc seq quot: ( obj assoc -- ) -- assoc )
rot (sequence>assoc) ; inline rot (sequence>assoc) ; inline
: sequence>assoc ( seq quot: ( obj assoc -- ) exemplar -- assoc ) : sequence>assoc ( seq quot: ( obj assoc -- ) exemplar -- assoc )
@ -73,8 +73,8 @@ PRIVATE>
: sequence>hashtable ( seq quot: ( obj hashtable -- ) -- hashtable ) : sequence>hashtable ( seq quot: ( obj hashtable -- ) -- hashtable )
H{ } sequence>assoc ; inline H{ } sequence>assoc ; inline
: histogram* ( hashtable seq -- hashtable ) : histogram! ( hashtable seq -- hashtable )
[ inc-at ] sequence>assoc* ; [ inc-at ] sequence>assoc! ;
: histogram ( seq -- hashtable ) : histogram ( seq -- hashtable )
[ inc-at ] sequence>hashtable ; [ inc-at ] sequence>hashtable ;