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

10
LINES

< > BotCompany Repo | #1009473 // textOut_and - join strings as "a, b and c"

JavaX fragment (include)

static S textOut_and(Collection<S> l) {
  ret textOut_and(l, "nothing");
}

static S textOut_and(Collection<S> l, S emptyText) {
  if (empty(l)) ret emptyText;
  L<S> separators = rep(", ", l(l)-2);
  separators.add(" and ");
  ret join_flex(separators, l);
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1009473
Snippet name: textOut_and - join strings as "a, b and c"
Eternal ID of this version: #1009473/6
Text MD5: cfe4b65660198197328745a2e308df5f
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-08-26 20:59:54
Source code size: 268 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 484 / 545
Version history: 5 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1009510 - textIn_or - split strings given as "a, b or c"
#1012368 - ai_renderAndList - synonym of textOut_and - join strings as "a, b and c"
#1017496 - textOut_or - join strings as "a, b or c"
#1018001 - joinWithComma_specialLast
#3000475 - Smart Bot's answer to: !fresh recentlyChangedSnippets()