{ $example "! Count the number of times letters and non-letters appear in a sequence."
"USING: prettyprint math.statistics unicode.categories ;"
"\"aaa123bc\" [ letter? ] histogram-by ."
- "H{ { f 3 } { t 5 } }"
+ "H{ { t 5 } { f 3 } }"
}
} ;
{ $description "Computes the index to begin searching from the hashcode of the key. Always outputs an even value since keys are stored at even indices of the underlying array." } ;
HELP: probe
-{ $values { "array" "the underlying array of a hashtable" } { "i" "a search index" } }
+{ $values { "array" "the underlying array of a hashtable" } { "i" "a search index" } { "probe#" "an incrementing counter" } }
{ $description "Outputs the next hashtable search index." } ;
HELP: key@
: hash@ ( key array -- i )
[ hashcode >fixnum dup fixnum+fast ] dip wrap ; inline
-: probe ( array i probe# -- array i' probe# )
+: probe ( array i probe# -- array i probe# )
2 fixnum+fast [ fixnum+fast over wrap ] keep ; inline
: no-key ( key array -- array n ? ) nip f f ; inline