2019-03-18 17:29:53 +01:00
|
|
|
# Unu: Simple, Literate Source Files
|
|
|
|
|
2021-05-12 15:57:22 +02:00
|
|
|
Retro is written in a literate style. Most of the sources
|
2019-03-18 17:29:53 +01:00
|
|
|
are in a format called Unu. This allows easy mixing of
|
|
|
|
commentary and code blocks, making it simple to document
|
|
|
|
the code.
|
|
|
|
|
|
|
|
As an example,
|
|
|
|
|
|
|
|
# Determine The Average Word Name Length
|
|
|
|
|
|
|
|
To determine the average length of a word name two values
|
|
|
|
are needed. First, the total length of all names in the
|
|
|
|
Dictionary:
|
|
|
|
|
|
|
|
~~~
|
|
|
|
#0 [ d:name s:length + ] d:for-each
|
|
|
|
~~~
|
|
|
|
|
|
|
|
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
|
|
|
|
~~~
|
|
|
|
|
|
|
|
This illustrates the format. Only code in the fenced blocks
|
|
|
|
(between \~~~ pairs) get extracted and run.
|
|
|
|
|
2020-09-25 19:05:29 +02:00
|
|
|
(Note: this only applies to source files; fences are not used
|
2019-03-18 17:29:53 +01:00
|
|
|
when entering code interactively).
|
2019-05-01 13:54:52 +02:00
|
|
|
|
|
|
|
## On The Name
|
|
|
|
|
|
|
|
The name Unu comes from the Maori language, where it means:
|
|
|
|
|
|
|
|
(verb) (-hia) pull out, withdraw, draw out, extract.
|
|
|
|
Taken from https://maoridictionary.co.nz/
|