fork download
  1. \ <r> n2 max+1 n3 min.
  2. : <range> ( nnn) within abort" range" ;
  3. : only ( n-n1/0) ?dup ;
  4. : except ( n-n0/1) ?dup 0= ;
  5. : 0exit except IF r> drop THEN ;
  6. : c@+ ( a-ca) dup c@ swap 1+ ;
  7.  
  8. \ fixed string arrays w/ offset idxing.
  9. \ c1 item width, c2 starting index.
  10. 0 Value nwid
  11. : Typers ( cc) Create c, dup to nwid
  12. 1+ c, does> ( u) c@+ >r - r>
  13. c@+ >r * r> + count type ;
  14. : n, ( ) parse-name nwid min dup c,
  15. here swap nwid allot move ;
  16.  
  17.  
  18. 9 1 Typers th-unit n, one n, two
  19. n, three n, four n, five n, six
  20. n, seven n, eight n, nine n, ten
  21. n, eleven n, twelve n, thirteen
  22. n, fourteen n, fifteen n, sixteen
  23. n, seventeen n, eighteen n, nineteen
  24.  
  25. 7 2 Typers th-ten n, twenty n, thirty
  26. n, forty n, fifty n, sixty n, seventy
  27. n, eighty n, ninety
  28.  
  29. : zero ." zero " ;
  30. : hundred ." hundred " ;
  31. : thousand ." thousand " ;
  32.  
  33. : -? dup IF '-' emit ELSE space THEN ;
  34. : triple ( u) 0exit 100 /mod only
  35. IF th-unit space hundred THEN dup 1
  36. 20 within IF th-unit space exit THEN
  37. 10 /mod only IF th-ten -? THEN
  38. 0exit th-unit ;
  39. : say-deci ( u) dup 1000000 0 <range>
  40. except IF zero exit THEN 1000 /mod
  41. only IF triple thousand THEN triple ;
  42.  
  43. cr .( decimal number names: )
  44. cr 4 th-ten \ forty
  45. cr 12 say-deci
  46. cr 69 say-deci
  47. cr 420 say-deci
  48. cr 105 say-deci
  49. cr 100010 say-deci
  50. cr
  51.  
  52.  
  53. #6 base !
  54.  
  55. 10 2 Typers th-six n, dozen
  56. n, thirsy n, forsy n, fifsy
  57.  
  58. : nif ." nif " ;
  59. : unexian ." unexian " ;
  60.  
  61. : pair ( u) 0exit dup 21 <
  62. IF th-unit space exit THEN 10 /mod
  63. only IF th-six -? THEN only
  64. IF th-unit space THEN ;
  65. : ?pair ( uf) IF drop ELSE pair THEN ;
  66. : quad ( u) 0exit 100 /mod only
  67. IF dup 1 = ?pair nif THEN pair ;
  68. : say-sexi ( u) dup 100000000 0 <range>
  69. except IF zero exit THEN 10000 /mod
  70. only IF quad unexian THEN quad ;
  71.  
  72. cr .( seximal number names: )
  73. cr 12 say-sexi
  74. cr 153 say-sexi \ sixty-nine.
  75. cr 420 say-sexi
  76. cr 105 say-sexi
  77. cr 1540 say-sexi \ four hundred twenty.
  78. cr 101425 say-sexi
  79. cr 54320000 say-sexi
  80.  
  81. decimal
  82.  
Success #stdin #stdout #stderr 0.01s 5272KB
stdin
Standard input is empty
stdout
decimal number names: 
forty
twelve 
sixty-nine
four hundred twenty 
one hundred five 
one hundred thousand ten 

seximal number names: 
eight 
nif fifsy-three 
four nif twelve 
nif five 
eleven nif forsy 
six unexian ten nif dozen-five 
fifsy-four nif thirsy-two unexian 
stderr
redefined Only with only  redefined c@+