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

8
LINES

< > BotCompany Repo | #1021364 // nTokens - get whitespace tokens. alternatively, render token count as string

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

Libraryless. Click here for Pure Java version (2209L/14K).

static LS nTokens(LS tok) {
  LS l = emptyList((l(tok)+1)/2);
  for (int i = 0; i < tok.size(); i += 2)
    l.add(tok.get(i));
  ret l;
}

sS nTokens(int n) { ret n2(n, "token"); }

Author comment

Began life as a copy of #1001111

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1021364
Snippet name: nTokens - get whitespace tokens. alternatively, render token count as string
Eternal ID of this version: #1021364/4
Text MD5: 73e040545580ed97fc01659fa4f378c0
Transpilation MD5: 4074ddb3b73ca1dde7811267744f3801
Author: stefan
Category: javax / tokenizing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-11-28 13:20:56
Source code size: 187 bytes / 8 lines
Pitched / IR pitched: No / No
Views / Downloads: 232 / 307
Version history: 3 change(s)
Referenced in: [show references]