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

12
LINES

< > BotCompany Repo | #1028695 // simpleSpacesAndTrim

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

Libraryless. Click here for Pure Java version (2545L/16K).

// Convert all spacing to a single space, so everything's neat & on one line.
static L<S> simpleSpacesAndTrim(L<S> tok) {
  tok = cloneList(tok);
  int n = l(tok);
  for (int i = 0; i < n; i += 2)
    tok.set(i, i == 0 || i == n-1 || empty(tok.get(i)) ? "" : " ");
  ret tok;
}

sS simpleSpacesAndTrim(S s) {
  ret join(simpleSpacesAndTrim(nlTok(s)));
}

Author comment

Began life as a copy of #1001975

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1028695
Snippet name: simpleSpacesAndTrim
Eternal ID of this version: #1028695/1
Text MD5: f04157c0dbb9a7e0e995cd37bf49f54a
Transpilation MD5: b4c84cfc9e9a82afc16d454dfdfacd67
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-05 21:25:23
Source code size: 364 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 116 / 191
Referenced in: [show references]