Libraryless. Click here for Pure Java version (2324L/15K).
1 | sclass Tok { |
2 | // either one can be null (bot not both) |
3 | S s; // joined |
4 | LS tok; // tokenized |
5 | |
6 | ITokenizer tokenizer; // optional |
7 | |
8 | *() {} |
9 | *(LS *tok) {} |
10 | |
11 | // a lambdaMapLike constructor - that's new |
12 | // use like: Tok javaTok("bla") |
13 | lambdaMapLike Tok(ITokenizer tokenizer, S s) { |
14 | this.tokenizer = tokenizer; |
15 | this.s = s; |
16 | } |
17 | |
18 | S text() { |
19 | if (s == null) s = join(tok); |
20 | ret s; |
21 | } |
22 | |
23 | LS tok() { |
24 | if (tok == null) tok = tokenizer.tokenize(s); |
25 | ret tok; |
26 | } |
27 | |
28 | // Note: toString can trigger tokenization |
29 | toString { ret appendSquareBracketed(text(), nTokens(countTokens(tok()))); } |
30 | } |
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1026190 |
Snippet name: | Tok - string with tokenization (lazily computed) |
Eternal ID of this version: | #1026190/11 |
Text MD5: | f77a0a561a0ca0d6dd36749857c8b727 |
Transpilation MD5: | 9485032fdbc5c36150b440337a1285c9 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-11-28 14:00:07 |
Source code size: | 655 bytes / 30 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 269 / 648 |
Version history: | 10 change(s) |
Referenced in: | [show references] |