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: 483 / 543
Version history: 5 change(s)
Referenced in: [show references]