How to resolve the algorithm Spelling of ordinal numbers step by step in the Quackery programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Spelling of ordinal numbers step by step in the Quackery 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 Quackery programming language

Source code in the quackery programming language

  [ name$
    dup -2 split nip
    [ switch
      $ "ne" case
        [ -3 split drop
          $ "first" join ]
      $ "wo" case
        [ -3 split drop
          $ "second" join ]
      $ "ee" case
        [ -3 split drop
          $ "ird" join ]
      $ "ve" case
        [ -2 split drop
          $ "fth" join ]
      $ "ht" case
        [ $ "h" join ]
      $ "ty" case
        [ -1 split drop
          $ "ieth" join ]
      otherwise
        [ $ "th" join ] ] ] is nameth$ ( n --> $ )

  ' [ 1 2 3 4 5 11 65 100 101 272 23456 8007006005004003 ]
  witheach
    [ dup echo say " = " nameth$ echo$ cr ]

  

You may also check:How to resolve the algorithm Square but not cube step by step in the Perl programming language
You may also check:How to resolve the algorithm N-smooth numbers step by step in the C# programming language
You may also check:How to resolve the algorithm Arithmetic/Complex step by step in the Bracmat programming language
You may also check:How to resolve the algorithm Flipping bits game step by step in the Phix programming language
You may also check:How to resolve the algorithm Munchausen numbers step by step in the 8080 Assembly programming language