fork download
  1. ;; https://p...content-available-to-author-only...s.com/2021/06/15/cardinal-and-ordinal-numbers/#respond
  2. ;;
  3. ;; Cardinal And Ordinal Numbers
  4. ;; June 15, 2021
  5. ;;
  6. ;; Cardinal numbers are those used for counting; spelled in letters, they
  7. ;; are one, two, three, four, and so on.
  8. ;;
  9. ;; Ordinal numbers are those used for ranking: spelled in letters, they
  10. ;; are first, second, third, fourth, and so on.
  11. ;;
  12. ;; Your task is to write a program that takes a number and returns the
  13. ;; spelled-out cardinal and ordinal forms of that number. When you are
  14. ;; finished, you are welcome to read or run a suggested solution, or to
  15. ;; post your own solution or discuss the exercise in the comments below.
  16.  
  17.  
  18. (defun card-ord (n)
  19. (values (format nil "~R" n)
  20. (format nil "~:R" n)))
  21.  
  22. (assert (equal (multiple-value-list (card-ord 42))
  23. '("forty-two"
  24. "forty-second")))
  25.  
  26. ;; Done.
  27.  
  28.  
  29. (defun main ()
  30. (loop for i below 111
  31. do (multiple-value-bind (card ord) (card-ord i)
  32. (format t "~A is ~A, the ~A number after 0.~%" i card ord))))
  33.  
  34. (main)
  35.  
Success #stdin #stdout 0.01s 25664KB
stdin
Standard input is empty
stdout
0 is zero, the zeroth number after 0.
1 is one, the first number after 0.
2 is two, the second number after 0.
3 is three, the third number after 0.
4 is four, the fourth number after 0.
5 is five, the fifth number after 0.
6 is six, the sixth number after 0.
7 is seven, the seventh number after 0.
8 is eight, the eighth number after 0.
9 is nine, the ninth number after 0.
10 is ten, the tenth number after 0.
11 is eleven, the eleventh number after 0.
12 is twelve, the twelfth number after 0.
13 is thirteen, the thirteenth number after 0.
14 is fourteen, the fourteenth number after 0.
15 is fifteen, the fifteenth number after 0.
16 is sixteen, the sixteenth number after 0.
17 is seventeen, the seventeenth number after 0.
18 is eighteen, the eighteenth number after 0.
19 is nineteen, the nineteenth number after 0.
20 is twenty, the twentieth number after 0.
21 is twenty-one, the twenty-first number after 0.
22 is twenty-two, the twenty-second number after 0.
23 is twenty-three, the twenty-third number after 0.
24 is twenty-four, the twenty-fourth number after 0.
25 is twenty-five, the twenty-fifth number after 0.
26 is twenty-six, the twenty-sixth number after 0.
27 is twenty-seven, the twenty-seventh number after 0.
28 is twenty-eight, the twenty-eighth number after 0.
29 is twenty-nine, the twenty-ninth number after 0.
30 is thirty, the thirtieth number after 0.
31 is thirty-one, the thirty-first number after 0.
32 is thirty-two, the thirty-second number after 0.
33 is thirty-three, the thirty-third number after 0.
34 is thirty-four, the thirty-fourth number after 0.
35 is thirty-five, the thirty-fifth number after 0.
36 is thirty-six, the thirty-sixth number after 0.
37 is thirty-seven, the thirty-seventh number after 0.
38 is thirty-eight, the thirty-eighth number after 0.
39 is thirty-nine, the thirty-ninth number after 0.
40 is forty, the fortieth number after 0.
41 is forty-one, the forty-first number after 0.
42 is forty-two, the forty-second number after 0.
43 is forty-three, the forty-third number after 0.
44 is forty-four, the forty-fourth number after 0.
45 is forty-five, the forty-fifth number after 0.
46 is forty-six, the forty-sixth number after 0.
47 is forty-seven, the forty-seventh number after 0.
48 is forty-eight, the forty-eighth number after 0.
49 is forty-nine, the forty-ninth number after 0.
50 is fifty, the fiftieth number after 0.
51 is fifty-one, the fifty-first number after 0.
52 is fifty-two, the fifty-second number after 0.
53 is fifty-three, the fifty-third number after 0.
54 is fifty-four, the fifty-fourth number after 0.
55 is fifty-five, the fifty-fifth number after 0.
56 is fifty-six, the fifty-sixth number after 0.
57 is fifty-seven, the fifty-seventh number after 0.
58 is fifty-eight, the fifty-eighth number after 0.
59 is fifty-nine, the fifty-ninth number after 0.
60 is sixty, the sixtieth number after 0.
61 is sixty-one, the sixty-first number after 0.
62 is sixty-two, the sixty-second number after 0.
63 is sixty-three, the sixty-third number after 0.
64 is sixty-four, the sixty-fourth number after 0.
65 is sixty-five, the sixty-fifth number after 0.
66 is sixty-six, the sixty-sixth number after 0.
67 is sixty-seven, the sixty-seventh number after 0.
68 is sixty-eight, the sixty-eighth number after 0.
69 is sixty-nine, the sixty-ninth number after 0.
70 is seventy, the seventieth number after 0.
71 is seventy-one, the seventy-first number after 0.
72 is seventy-two, the seventy-second number after 0.
73 is seventy-three, the seventy-third number after 0.
74 is seventy-four, the seventy-fourth number after 0.
75 is seventy-five, the seventy-fifth number after 0.
76 is seventy-six, the seventy-sixth number after 0.
77 is seventy-seven, the seventy-seventh number after 0.
78 is seventy-eight, the seventy-eighth number after 0.
79 is seventy-nine, the seventy-ninth number after 0.
80 is eighty, the eightieth number after 0.
81 is eighty-one, the eighty-first number after 0.
82 is eighty-two, the eighty-second number after 0.
83 is eighty-three, the eighty-third number after 0.
84 is eighty-four, the eighty-fourth number after 0.
85 is eighty-five, the eighty-fifth number after 0.
86 is eighty-six, the eighty-sixth number after 0.
87 is eighty-seven, the eighty-seventh number after 0.
88 is eighty-eight, the eighty-eighth number after 0.
89 is eighty-nine, the eighty-ninth number after 0.
90 is ninety, the ninetieth number after 0.
91 is ninety-one, the ninety-first number after 0.
92 is ninety-two, the ninety-second number after 0.
93 is ninety-three, the ninety-third number after 0.
94 is ninety-four, the ninety-fourth number after 0.
95 is ninety-five, the ninety-fifth number after 0.
96 is ninety-six, the ninety-sixth number after 0.
97 is ninety-seven, the ninety-seventh number after 0.
98 is ninety-eight, the ninety-eighth number after 0.
99 is ninety-nine, the ninety-ninth number after 0.
100 is one hundred, the one hundredth number after 0.
101 is one hundred one, the one hundred first number after 0.
102 is one hundred two, the one hundred second number after 0.
103 is one hundred three, the one hundred third number after 0.
104 is one hundred four, the one hundred fourth number after 0.
105 is one hundred five, the one hundred fifth number after 0.
106 is one hundred six, the one hundred sixth number after 0.
107 is one hundred seven, the one hundred seventh number after 0.
108 is one hundred eight, the one hundred eighth number after 0.
109 is one hundred nine, the one hundred ninth number after 0.
110 is one hundred ten, the one hundred tenth number after 0.