\ < r> n2 max+ 1 n3 min.
: < range
> ( nnn
) within
abort " range" ; : only ( n- n1/ 0 ) ? dup ;
: except ( n- n0/ 1 ) ? dup 0 = ;
: 0exit except IF r> drop THEN ;
: c@+ ( a- ca) dup c@ swap 1 + ;
\ fixed string arrays w/ offset idxing.
\ c1 item width, c2 starting index.
0 Value nwid
: Typers ( cc) Create c, dup to nwid
1 + c, does> ( u) c@+ > r - r>
c@+ > r * r> + count type ;
: n, ( ) parse- name nwid min dup c,
here swap nwid allot move ;
9 1 Typers th- unit n, one n, two
n, three n, four n, five n, six
n, seven n, eight n, nine n, ten
n, eleven n, twelve n, thirteen
n, fourteen n, fifteen n, sixteen
n, seventeen n, eighteen n, nineteen
7 2 Typers th- ten n, twenty n, thirty
n, forty n, fifty n, sixty n, seventy
n, eighty n, ninety
: zero ." zero " ;
: hundred ." hundred " ;
: thousand ." thousand " ;
: -? dup IF '-' emit ELSE space THEN ;
: triple ( u) 0exit 100 / mod only
IF th- unit space hundred THEN dup 1
20 within IF th
- unit space
exit THEN
10 / mod only IF th- ten -? THEN
0exit th- unit ;
: say- deci ( u) dup 1000000 0 < range>
except IF zero
exit THEN
1000 / mod
only IF triple thousand THEN triple ;
cr .( decimal number names: )
cr 4 th- ten \ forty
cr 12 say- deci
cr 69 say- deci
cr 420 say- deci
cr 105 say- deci
cr 100010 say- deci
cr
#6 base !
10 2 Typers th- six n, dozen
n, thirsy n, forsy n, fifsy
: nif ." nif " ;
: unexian ." unexian " ;
: pair ( u) 0exit dup 21 <
IF th
- unit space
exit THEN
10 / mod
only IF th- six -? THEN only
IF th- unit space THEN ;
: ? pair ( uf) IF drop ELSE pair THEN ;
: quad ( u) 0exit 100 / mod only
IF dup 1 = ? pair nif THEN pair ;
: say- sexi ( u) dup 100000000 0 < range>
except IF zero
exit THEN
10000 / mod
only IF quad unexian THEN quad ;
cr .( seximal number names: )
cr 12 say- sexi
cr 153 say- sexi \ sixty- nine.
cr 420 say- sexi
cr 105 say- sexi
cr 1540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