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

11
LINES

< > BotCompany Repo | #1001975 // simpleSpaces

JavaX fragment (include)

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

static S simpleSpaces(S s) {
  ret join(simpleSpaces(nlTok(s)));
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1001975
Snippet name: simpleSpaces
Eternal ID of this version: #1001975/2
Text MD5: d3b8316f997fc19b82813a39753946f2
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-11-30 00:51:46
Source code size: 317 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 629 / 907
Version history: 1 change(s)
Referenced in: #1002427 - Accellerating 629 (SPIKE)
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1017486 - simpleSpaces2 - only convert whitespace, leave all other punctuation alone
#1024146 - simpleSpaces_javaTok
#1027357 - simpleSpaces_trim
#1028695 - simpleSpacesAndTrim
#3000382 - Answer for ferdie (>> t = 1, f = 0)