Functions for working with the idealized calendar of Planet Xhilr
Revisión | 4f7b85262577dd943ed5ce8fc566cbb8cafeb48e (tree) |
---|---|
Tiempo | 2017-06-13 17:30:52 |
Autor | Joel Matthew Rees <joel.rees@gmai...> |
Commiter | Joel Matthew Rees |
checking my math
@@ -0,0 +1,37 @@ | ||
1 | +( Forth code for showing fractions. ) | |
2 | +( by Joel Matthew Rees, winter/spring 2017. ) | |
3 | +( Copyright 2017, Joel Matthew Rees ) | |
4 | + | |
5 | +( Permission granted to use for personal entertainment only. ) | |
6 | + | |
7 | +( http://joel-rees-economics.blogspot.com/2017/04/soc500-03-09-calculating-skip-years.html ) | |
8 | + | |
9 | +( Using integer math. ) | |
10 | +( Forth expression syntax is mostly postfix. ) | |
11 | + | |
12 | +( Hopefully, some definitions here will make things more readable. ) | |
13 | + | |
14 | +: PRCH EMIT ; | |
15 | + | |
16 | +: COMMA 44 PRCH ; | |
17 | +: COLON 58 PRCH ; | |
18 | + | |
19 | +( No trailing space. ) | |
20 | +: PSNUM ( number -- ) | |
21 | + 0 .R ; | |
22 | + | |
23 | + | |
24 | +: NUMERATORS ( count -- ) | |
25 | +DUP 1+ 0 DO | |
26 | + I PSNUM COLON SPACE | |
27 | + I 1000 * OVER / PSNUM COMMA ( 1000 times I divided by count ) | |
28 | + SPACE LOOP | |
29 | +DROP ; | |
30 | + | |
31 | +: FRACTIONS ( count -- ) | |
32 | +CR | |
33 | +1+ 1 DO | |
34 | + I PSNUM SPACE I NUMERATORS CR | |
35 | +LOOP ; | |
36 | + | |
37 | + |