How to resolve the algorithm Spelling of ordinal numbers step by step in the Common Lisp programming language
How to resolve the algorithm Spelling of ordinal numbers step by step in the Common Lisp programming language
Table of Contents
Problem Statement
Ordinal numbers (as used in this Rosetta Code task), are numbers that describe the position of something in a list. It is this context that ordinal numbers will be used, using an English-spelled name of an ordinal number.
The ordinal numbers are (at least, one form of them): sometimes expressed as:
For this task, the following (English-spelled form) will be used:
Furthermore, the short scale numbering system (i.e. 2,000,000,000 is two billion) will be used here. wp:Long and short scales 2,000,000,000 is two billion, not two milliard.
Write a driver and a function (subroutine/routine ···) that returns the English-spelled ordinal version of a specified number (a positive integer). Optionally, try to support as many forms of an integer that can be expressed: 123 00123.0 1.23e2 all are forms of the same integer. Show all output here.
Use (at least) the test cases of:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Spelling of ordinal numbers step by step in the Common Lisp programming language
Source code in the common programming language
(defun ordinal-number (n)
(format nil "~:R" n))
#|
CL-USER> (loop for i in '(1 2 3 4 5 11 65 100 101 272 23456 8007006005004003)
do (format t "~a: ~a~%" i (ordinal-number i)))
1: first
2: second
3: third
4: fourth
5: fifth
11: eleventh
65: sixty-fifth
100: one hundredth
101: one hundred first
272: two hundred seventy-second
23456: twenty-three thousand four hundred fifty-sixth
8007006005004003: eight quadrillion seven trillion six billion five million four thousand third
NIL
|#
You may also check:How to resolve the algorithm Isqrt (integer square root) of X step by step in the SETL programming language
You may also check:How to resolve the algorithm System time step by step in the Standard ML programming language
You may also check:How to resolve the algorithm Narcissist step by step in the Nanoquery programming language
You may also check:How to resolve the algorithm Write to Windows event log step by step in the Wren programming language
You may also check:How to resolve the algorithm Currying step by step in the F# programming language