1 | static L<S> countFixer_them = splitAtSpace("nd st rd th");
|
2 | |
3 | static S countFixer(S s) {
|
4 | L<S> tok = nlTok2(s); |
5 | for (int i = 1; i+2 < l(tok); i += 2) |
6 | if (isInteger(tok.get(i)) && contains(countFixer_them, tok.get(i+2))) pcall {
|
7 | // Is it correct? |
8 | long l = parseLong(tok.get(i)); |
9 | long d = l % 10, h = l % 100; |
10 | tok.set(i+2, h-d == 10 ? "th" |
11 | : d == 1 ? "st" |
12 | : d == 2 ? "nd" |
13 | : d == 3 ? "rd" |
14 | : "th"); |
15 | } |
16 | ret join(tok); |
17 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1003503 |
| Snippet name: | countFixer - fixes 1st, 2nd etc. |
| Eternal ID of this version: | #1003503/1 |
| Text MD5: | aec9d577b0e540bb51d8921ed2378e96 |
| Author: | stefan |
| Category: | javax / talking robots |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-07-10 00:33:18 |
| Source code size: | 496 bytes / 17 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 796 / 809 |
| Referenced in: | [show references] |