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

46
LINES

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

JavaX fragment (include)

static S n2(long l) { ret formatWithThousands(l); }
static S n2(Collection l) { ret n2(l(l)); }

sS n2(double l, S singular) {
  ret n2(l, singular, singular + "s");
}

sS n2(double l, S singular, S plural) {
  if (fraction(l) == 0)
    ret n2((long) l, singular, plural);
  else
    ret l + " " + plural;
}

static S n2(long l, S singular, S plural) {
  ret n_fancy2(l, singular, plural);
}

static S n2(long l, S singular) {
  ret n_fancy2(l, singular, singular + "s");
}

static S n2(Collection l, S singular) {
  ret n2(l(l), singular);
}

static S n2(Collection l, S singular, S plural) {
  ret n_fancy2(l, singular, plural);
}

static S n2(Map m, S singular, S plural) {
  ret n_fancy2(m, singular, plural);
}

static S n2(Map m, S singular) {
  ret n2(l(m), singular);
}

static S n2(O[] a, S singular) { ret n2(l(a), singular); }
static S n2(O[] a, S singular, S plural) { ret n_fancy2(a, singular, plural); }

ifclass MultiSet
  static S n2(MultiSet ms, S singular, S plural) {
    ret n_fancy2(ms, singular, plural);
  }
endif

Author comment

Began life as a copy of #1012450

download  show line numbers  debug dex   

Travelled to 10 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1012632
Snippet name: n2 - n2(3, "item") => "3 items"
Eternal ID of this version: #1012632/14
Text MD5: 78c2a7ed52ba672b4c13fccf4db5812a
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-11-30 18:19:34
Source code size: 1081 bytes / 46 lines
Pitched / IR pitched: No / No
Views / Downloads: 181 / 257
Version history: 13 change(s)
Referenced in: [show references]