Lingua:...Ordinate(3)
π NAME π
okay so this is the <pink>Lingua:...Ordinate(3)</pink> page from User Contributed Perl Documentation, and it's literally about the module Lingua::EN::Numbers::Ordinate β the one that takes a cardinal number like 3 and gives you the ordinal "3rd". bestie, it's giving βnumber glow-up,β no cap. π
β¨ SYNOPSIS β¨
okay, here's the vibe in code:
use Lingua::EN::Numbers::Ordinate;
print ordinate(4), "\n";
# prints 4th
print ordinate(-342), "\n";
# prints -342nd
# Example of actual use:
...
for(my $i = 0; $i < @records; $i++) {
unless(is_valid($record[$i]) {
warn "The ", ordinate($i), " record is invalid!\n";
next;
}
...
}
π¦ DESCRIPTION π¦
English has two kinds of numbers, bestie: cardinals (1, 2, 3...) and ordinals (1st, 2nd, 3rd...). This library provides functions for giving the ordinal form of a number, given its cardinal value. That's the whole assignment, and it ate. π
π FUNCTIONS π
ordinate(SCALAR)β returns a string consisting of that scalar's string form, plus the appropriate ordinal suffix. Example:ordinate(23)returns"23rd".
As a special case, ordinate(undef) and ordinate("") return "0th", not "th".
This function is exported by default. π«Ά
th(SCALAR)β merely an alias for"ordinate", but not exported by default.ordsuf(SCALAR)β returns just the appropriate ordinal suffix for the given scalar numeric value. This is what"ordinate"uses to actually do its work. For example,ordsuf(3)is"rd".
Not exported by default.
The above functions are all prototyped to take a scalar value, so ordinate(@stuff) is the same as "ordinate(scalar @stuff)". slay. β¨
π CAVEATS π
- Note that this library knows only about numbers, not number-words.
ordinate('seven')might just as well beordinate('superglue')orordinate("\x1E\x9A")β you'll get the fallthru case of the input string plus"th". lowkey chaotic, but that's the deal. π - As is unavoidable,
ordinate(0256)returns"174th"(becauseordinatesees the value174). Similarly,ordinate(1E12)returns"1000000000000th". Returning"trillionth"would be nice, but that's an awfully atypical case. - Note that this library's algorithm (as well as the basic concept and implementation of ordinal numbers) is totally language specific. π§
To pick a trivial example, consider that in French, 1 ordinates as "1ier", whereas 41 ordinates as "41ieme".
π SEE ALSO π
Lingua::EN::Inflectprovides an"ORD"function, which returns the ordinal form of a cardinal number.Lingua::EN::Number::IsOrdinalprovides an"is_ordinal"function, which returns true if passed an ordinal number.Lingua::EN::Numbersprovides functionnum2en_ordinal()which will take a number and return the ordinal as a word. So3will result in"third".
β REPOSITORY β
the repo lives at https://github.com/neilb/Lingua-EN-Numbers-Ordinate β go peek if you're nosy, bestie.
π COPYRIGHT π
Copyright (c) 2000 Sean M. Burke. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
πΈ AUTHOR πΈ
Sean M. Burke "sburke@cpan.org"
This has been maintained by Neil Bowers (NEILB) since 2014.
okay that's the page, bestie! source/version check: perl v5.42.2, date 2023-10-09 β mwah ππ
π¦ where this page comes from
- alpine 3.24: perl-lingua-en-numbers-ordinate-doc 1.05-r2 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms