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

9
LINES

< > BotCompany Repo | #1002113 // getPlural - don't degrade this, it's used!

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

Libraryless. Click here for Pure Java version (4029L/23K).

static Set<S> getPlural_specials = litciset("sheep", "fish");

static S getPlural(S s) {
  if (contains(getPlural_specials, s)) ret s;
  if (ewic(s, "y")) ret dropSuffixIgnoreCase("y", s) + "ies";
  if (ewicOneOf(s, "ss", "ch")) ret s + "es";
  if (ewic(s, "s")) ret s;
  ret s + "s";
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1002113
Snippet name: getPlural - don't degrade this, it's used!
Eternal ID of this version: #1002113/4
Text MD5: 773cd835e42f7c4cb541faf2749ec7a4
Transpilation MD5: 27713b4707e05986712ea34c292982f7
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-14 16:11:07
Source code size: 294 bytes / 9 lines
Pitched / IR pitched: No / No
Views / Downloads: 819 / 2313
Version history: 3 change(s)
Referenced in: #1002427 - Accellerating 629 (SPIKE)
#1002455 - plural - synonym of getPlural
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#3000382 - Answer for ferdie (>> t = 1, f = 0)