| | 7 | ( NOTE: ) |
| | 8 | ( ----- ) |
| | 9 | ( ) |
| | 10 | ( Since altering 'hash-prime' would affect previously written ) |
| | 11 | ( tables, we shall introduce the following condition: you may ) |
| | 12 | ( modify 'hash-prime' before creating hash-tables, but once ) |
| | 13 | ( this has been done, do NOT change its value afterward. ) |
| | 14 | ( ) |
| | 15 | ( Of course, we could make 'hash' more flexible and have it ) |
| | 16 | ( read a prime value [or define a second word that respects a ) |
| | 17 | ( stack value for modding]. For now, let's just regard our ) |
| | 18 | ( stipulation as well justified; either tweak the provided ) |
| | 19 | ( hashing routines _before_ use, or leave them be. ) |
| | 20 | ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) |
| | 65 | |
| | 66 | : 'type' ( $- ) char: ' emit type char: ' emit space ; |
| | 67 | |
| | 68 | {{ |
| | 69 | : bkt-keys ( l- ) repeat 0; dup 1+ @ @ , @ again drop ; |
| | 70 | : (keys) ( t- ) hash-prime @ for @+ bkt-keys next drop ; |
| | 71 | ---reveal--- |
| | 72 | : keys ( t-a ) |
| | 73 | here 0 , swap (keys) here over - 1- over ! ; |
| | 74 | }} |
| | 75 | |
| | 76 | : keys{ ( R: t- ) ` keys ` dup ` push ` foreach{ ; compile-only |
| | 77 | : }keys ( R: - ) ` }loop ` pop ` here ` - ` allot ; compile-only |
| | 78 | |
| | 79 | : .keys ( t- ) |
| | 80 | char: { emit space keys{ 'type' }keys char: } emit ; |
| | 81 | |
| | 82 | ( xyz -> xyzx: like 'rot', but _copies_ rotated item ) |
| | 83 | : rover ` push ` over ` pop ` swap ; compile-only |
| | 84 | |
| | 85 | : .table ( t- ) |
| | 86 | dup |
| | 87 | keys{ dup cr 'type' ." => " rover get-entry drop . }keys |
| | 88 | drop ; |