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

13
LINES

< > BotCompany Repo | #1008636 // tokenToCharIndex

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

Libraryless. Click here for Pure Java version (4612L/26K).

ifclass ListAndIndex
static int tokenToCharIndex(ListAndIndex<S> ptr) {
  ret ptr == null ? -1 : tokenToCharIndex(ptr.list(), ptr.idx());
}
endif

static int tokenToCharIndex(LS tok, int tokenIndex) {
  if (tokenIndex < 0) ret -1;
  int idx = 0;
  tokenIndex = min(tokenIndex, l(tok));
  for i to tokenIndex: idx += l(tok.get(i));
  ret idx;
}

Author comment

Began life as a copy of #1008633

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: #1008636
Snippet name: tokenToCharIndex
Eternal ID of this version: #1008636/5
Text MD5: 75eed022ff490397042e48f651197859
Transpilation MD5: e60cff8d4a031d5513033f296e0d042e
Author: stefan
Category: javax / parsing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-15 20:20:57
Source code size: 355 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 487 / 549
Version history: 4 change(s)
Referenced in: [show references]