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

11
LINES

< > BotCompany Repo | #1028919 // nlJoin - join strings in a natural way (with spaces in the right places)

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

Transpiled version (2520L) is out of date.

sS nlJoin(Iterable<S> l) {
  new StringBuilder buf;
  S last = "";
  fOr (S s : l) {
    if (nempty(last) && (startsWithLetterOrDigit(s) || startsWith(s, "$")))
      buf.append(" ");
    buf.append(s);
    if (nempty(s)) last = s;
  }
  ret str(buf);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028919
Snippet name: nlJoin - join strings in a natural way (with spaces in the right places)
Eternal ID of this version: #1028919/3
Text MD5: 2662854d835f6e7532c3f731a6aead27
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-11 22:05:21
Source code size: 263 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 195 / 276
Version history: 2 change(s)
Referenced in: [show references]