example showing use of d:for-each
to calculate dictionary stats
FossilOrigin-Name: 34cc637d020e1ddff2929ad9131e51e4319b61adf4a2efd59ef5e9e6484e5d04
This commit is contained in:
parent
3731319e07
commit
b1681857c8
1 changed files with 23 additions and 0 deletions
23
example/DictionaryStats.forth
Normal file
23
example/DictionaryStats.forth
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
It's sometimes interesting to take some measurements of dictionary names.
|
||||||
|
|
||||||
|
Determine the number of words in the dictionary.
|
||||||
|
|
||||||
|
~~~
|
||||||
|
#0 [ drop n:inc ] d:for-each
|
||||||
|
'%n_names_defined\n s:with-format puts
|
||||||
|
~~~
|
||||||
|
|
||||||
|
Determine the average length of a word name.
|
||||||
|
|
||||||
|
~~~
|
||||||
|
#0 [ d:name s:length + ] d:for-each
|
||||||
|
#0 [ drop n:inc ] d:for-each
|
||||||
|
/ 'Average_name_length:_%n\n s:with-format puts
|
||||||
|
~~~
|
||||||
|
|
||||||
|
Longest name are...
|
||||||
|
|
||||||
|
~~~
|
||||||
|
#0 [ d:name s:length n:max ] d:for-each
|
||||||
|
'Longest_names_are_%n_characters\n s:with-format puts
|
||||||
|
~~~
|
Loading…
Reference in a new issue