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.

1  
sS nlJoin(Iterable<S> l) {
2  
  new StringBuilder buf;
3  
  S last = "";
4  
  fOr (S s : l) {
5  
    if (nempty(last) && (startsWithLetterOrDigit(s) || startsWith(s, "$")))
6  
      buf.append(" ");
7  
    buf.append(s);
8  
    if (nempty(s)) last = s;
9  
  }
10  
  ret str(buf);
11  
}

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: 197 / 279
Version history: 2 change(s)
Referenced in: [show references]