RosettaCodeData/Task/Documentation/Retro/documentation.retro

29 lines
521 B
Text
Raw Permalink Normal View History

2020-02-17 23:21:07 -08:00
# Determine The Average Word Name Length
2013-04-10 22:43:41 -07:00
2020-02-17 23:21:07 -08:00
To determine the average length of a word name two values
are needed. First, the total length of all names in the
Dictionary:
2013-04-10 22:43:41 -07:00
2020-02-17 23:21:07 -08:00
~~~
#0 [ d:name s:length + ] d:for-each
~~~
2013-04-10 22:43:41 -07:00
2020-02-17 23:21:07 -08:00
And then the number of words in the Dictionary:
~~~
#0 [ drop n:inc ] d:for-each
~~~
With these, a simple division is all that's left.
~~~
/
~~~
Finally, display the results:
~~~
'Average_name_length:_%n\n s:format s:put
~~~