September Morn Update

This commit is contained in:
Ingy döt Net 2019-09-12 10:33:56 -07:00
parent 4e2d22a71d
commit aac6731f2c
6856 changed files with 141342 additions and 21127 deletions

View file

@ -1,29 +1,29 @@
import extensions.
import system'math.
import system'routines.
import extensions;
import system'math;
import system'routines;
extension op
{
ordinalize
[
int i := self absolute.
if ((11,12,13) ifExists(i mod:100))
[
^ i literal + "th".
].
ordinalize()
{
int i := self.Absolute;
if (new int[]{11,12,13}.ifExists(i.mod:100))
{
^ i.Printable + "th"
};
(i mod:10) =>
1 [ ^ i literal + "st" ];
2 [ ^ i literal + "nd" ];
3 [ ^ i literal + "rd" ].
i.mod:10 =>
1 { ^ i.Printable + "st" }
2 { ^ i.Printable + "nd" }
3 { ^ i.Printable + "rd" };
^ i literal + "th".
]
^ i.Printable + "th"
}
}
program =
[
console printLine(Range new(0,26); selectBy:%"op.ordinalize").
console printLine(Range new(250,26); selectBy:%"op.ordinalize").
console printLine(Range new(1000,26); selectBy:%"op.ordinalize").
].
public program()
{
console.printLine(new Range(0,26).selectBy(mssgconst ordinalize<op>[0]));
console.printLine(new Range(250,26).selectBy(mssgconst ordinalize<op>[0]));
console.printLine(new Range(1000,26).selectBy(mssgconst ordinalize<op>[0]))
}