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).

1  
static LS nTokens(LS tok) {
2  
  LS l = emptyList((l(tok)+1)/2);
3  
  for (int i = 0; i < tok.size(); i += 2)
4  
    l.add(tok.get(i));
5  
  ret l;
6  
}
7  
8  
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: 303 / 393
Version history: 3 change(s)
Referenced in: [show references]