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

61
LINES

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

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

Transpiled version (5335L) is out of date.

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_getPlural(S singular) {
7  
  //ret singular + "s";
8  
  ret plural(singular);
9  
}
10  
11  
sS n2(double l, S singular) {
12  
  ret empty(singular) ? str(l) : n2(l, singular, n2_getPlural(singular));
13  
}
14  
15  
sS n2(double l, S singular, S plural) {
16  
  if (fraction(l) == 0)
17  
    ret n2((long) l, singular, plural);
18  
  else
19  
    ret l + " " + plural;
20  
}
21  
22  
static S n2(long l, S singular, S plural) {
23  
  ret n_fancy2(l, singular, plural);
24  
}
25  
26  
static S n2(long l, S singular) {
27  
  ret empty(singular) ? n2(l) : n_fancy2(l, singular, n2_getPlural(singular));
28  
}
29  
30  
static S n2(Collection l, S singular) {
31  
  ret n2(l(l), singular);
32  
}
33  
34  
static S n2(Collection l, S singular, S plural) {
35  
  ret n_fancy2(l, singular, plural);
36  
}
37  
38  
static S n2(Map m, S singular, S plural) {
39  
  ret n_fancy2(m, singular, plural);
40  
}
41  
42  
static S n2(Map m, S singular) {
43  
  ret n2(l(m), singular);
44  
}
45  
46  
static S n2(long[] a, S singular) { ret n2(l(a), singular); }
47  
48  
static S n2(O[] a, S singular) { ret n2(l(a), singular); }
49  
static S n2(O[] a, S singular, S plural) { ret n_fancy2(a, singular, plural); }
50  
51  
ifclass MultiSet
52  
  static S n2(MultiSet ms, S singular, S plural default n2_getPlural(singular)) {
53  
    ret n_fancy2(ms, singular, plural);
54  
  }
55  
endif
56  
57  
ifclass IMultiMap
58  
  static S n2(IMultiMap mm, S singular, S plural default n2_getPlural(singular)) {
59  
    ret n_fancy2(l(mm), singular, plural);
60  
  }
61  
endif

Author comment

Began life as a copy of #1012450

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1012632
Snippet name: n2 - n2(3, "item") => "3 items"
Eternal ID of this version: #1012632/24
Text MD5: 21a1e958d9ce11a29a04dc306488d0f0
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-11-07 12:39:49
Source code size: 1578 bytes / 61 lines
Pitched / IR pitched: No / No
Views / Downloads: 761 / 1007
Version history: 23 change(s)
Referenced in: [show references]