Spelling of ordinal numbers: Difference between revisions
m
→{{header|Perl 6}}: Update for module change
(Added Sidef) |
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: Update for module change) |
||
Line 533:
=={{header|Perl 6}}==
{{works with|Rakudo|2017.08}}
This would be pretty simple to implement from scratch; it would be straightforward to do a minor modification of the [[Number_names#Perl_6| Number names]] task code. Much simpler to just use the Lingua::EN::Numbers
We need to be slightly careful of terminology. In Perl 6, 123, 00123.0, & 1.23e2 are not all integers. They are respectively an Int (integer), a Rat (rational number) and a Num (floating point number). (The fourth numeric is a Complex) For this task it doesn't much matter as the ordinal routine coerces its argument to an Int, but to Perl 6 they are different things. We can further abuse allomorphic types and role mixins for some somewhat non-intuitive results as well.
Line 543:
It is not really clear what is meant by "Write a driver and a function...". Well, the function part is clear enough; driver not so much. Perhaps this will suffice.
<lang perl6>use Lingua::EN::Numbers
printf( "\%16s : %s\n", $_, ordinal($_) ) for
|