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

17
LINES

< > BotCompany Repo | #1021215 // ai_withTokenRefNumbers

JavaX fragment (include)

1  
sS ai_withTokenRefNumbers(L<TokenAndRange> tokens, Map<TokenAndRange> map) {
2  
  Set<TokenAndRange> refd = valuesSet(map);
3  
  int n = 0;
4  
  new StringBuilder buf;
5  
  new Map<TokenAndRange, Int> indices;
6  
  for (TokenAndRange t : tokens) {
7  
    buf.append(t.token);
8  
    if (refd.contains(t)) {
9  
      indices.put(t, ++n);
10  
      buf.append(" [*" + n + "]");
11  
    }
12  
    TokenAndRange target = mapGet(map, t);
13  
    if (target != null)
14  
      buf.append(" [" + indices.get(target) + "]");
15  
  }
16  
  ret str(buf);
17  
}

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: #1021215
Snippet name: ai_withTokenRefNumbers
Eternal ID of this version: #1021215/4
Text MD5: 08a9a7d472125552caab79b1e9274d8b
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-02-03 15:58:33
Source code size: 510 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 300 / 351
Version history: 3 change(s)
Referenced in: [show references]