1 | static LL<S> ai_spreadCertainIndices(L<S> tokPat, L<S> tokS, L<Int> indices) { |
2 | int extra = l(tokS)-l(tokPat); |
3 | if (extra < 0 || empty(indices)) ret emptyList(); |
4 | |
5 | new LL<S> results; |
6 | for (L<Int> spread : allSpreads(extra, l(indices))) { |
7 | new L<S> tok; |
8 | int pos = 0, iSpread = 0, iIndices = 0; |
9 | for i over tokPat: |
10 | if (!eq(get(indices, iIndices), i)) |
11 | tok.add(tokS.get(pos++)); |
12 | else { |
13 | ++iIndices; |
14 | int take = spread.get(iSpread++); |
15 | tok.add(join(subList(tokS, pos, pos+take+1))); |
16 | pos += take+1; |
17 | } |
18 | results.add(tok); |
19 | } |
20 | ret results; |
21 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1017287 |
Snippet name: | ai_spreadCertainIndices - works on CNC |
Eternal ID of this version: | #1017287/7 |
Text MD5: | 45b019d4638edc485cd23da8a9a07084 |
Author: | stefan |
Category: | javax / parsing |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-09-30 02:26:40 |
Source code size: | 626 bytes / 21 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 324 / 365 |
Version history: | 6 change(s) |
Referenced in: | [show references] |