Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

50
LINES

< > BotCompany Repo | #1012632 // n2 - n2(3, "item") => "3 items"

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3883L/22K).

1  
static S n2(long l) { ret formatWithThousands(l); }
2  
static S n2(AtomicLong l) { ret n2(l!); }
3  
static S n2(Collection l) { ret n2(l(l)); }
4  
static S n2(Map map) { ret n2(l(map)); }
5  
6  
sS n2(double l, S singular) {
7  
  ret empty(singular) ? str(l) : n2(l, singular, singular + "s");
8  
}
9  
10  
sS n2(double l, S singular, S plural) {
11  
  if (fraction(l) == 0)
12  
    ret n2((long) l, singular, plural);
13  
  else
14  
    ret l + " " + plural;
15  
}
16  
17  
static S n2(long l, S singular, S plural) {
18  
  ret n_fancy2(l, singular, plural);
19  
}
20  
21  
static S n2(long l, S singular) {
22  
  ret empty(singular) ? n2(l) : n_fancy2(l, singular, singular + "s");
23  
}
24  
25  
static S n2(Collection l, S singular) {
26  
  ret n2(l(l), singular);
27  
}
28  
29  
static S n2(Collection l, S singular, S plural) {
30  
  ret n_fancy2(l, singular, plural);
31  
}
32  
33  
static S n2(Map m, S singular, S plural) {
34  
  ret n_fancy2(m, singular, plural);
35  
}
36  
37  
static S n2(Map m, S singular) {
38  
  ret n2(l(m), singular);
39  
}
40  
41  
static S n2(long[] a, S singular) { ret n2(l(a), singular); }
42  
43  
static S n2(O[] a, S singular) { ret n2(l(a), singular); }
44  
static S n2(O[] a, S singular, S plural) { ret n_fancy2(a, singular, plural); }
45  
46  
ifclass MultiSet
47  
  static S n2(MultiSet ms, S singular, S plural) {
48  
    ret n_fancy2(ms, singular, plural);
49  
  }
50  
endif

Author comment

Began life as a copy of #1012450

download  show line numbers  debug dex  old transpilations   

Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1012632
Snippet name: n2 - n2(3, "item") => "3 items"
Eternal ID of this version: #1012632/21
Text MD5: ff733623db689cbf8d661f8cfcca154b
Transpilation MD5: 83f537dfcd8a227bee64051a7ac1d947
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-07 09:03:23
Source code size: 1284 bytes / 50 lines
Pitched / IR pitched: No / No
Views / Downloads: 415 / 546
Version history: 20 change(s)
Referenced in: [show references]