Libraryless. Click here for Pure Java version (2582L/16K).
1 | static ItIt<LS> ai_spreadCertainIndices_2_iterator(LS tokPat, LS tokS, L<Int> indices) { |
2 | int extra = (l(tokS)-l(tokPat))/2; |
3 | if (extra < 0 || empty(indices)) ret emptyItIt(); |
4 | |
5 | ret mapI(allSpreads(extra, l(indices)), spread -> { |
6 | new LS tok; |
7 | int pos = 0, iSpread = 0, iIndices = 0; |
8 | for i over tokPat: |
9 | if (!eq(get(indices, iIndices), i)) |
10 | tok.add(tokS.get(pos++)); |
11 | else { |
12 | ++iIndices; |
13 | int take = spread.get(iSpread++)*2; |
14 | tok.add(joinSubList(tokS, pos, pos+take+1)); |
15 | pos += take+1; |
16 | } |
17 | ret tok; |
18 | }); |
19 | } |
Began life as a copy of #1021071
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: | #1026120 |
Snippet name: | ai_spreadCertainIndices_2_iterator - works on CNC |
Eternal ID of this version: | #1026120/1 |
Text MD5: | 8b37f00fee7976a0ba3bc94092e22db8 |
Transpilation MD5: | 097f7e4967a785c58ea03a881f2f769d |
Author: | stefan |
Category: | javax / parsing |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-11-25 20:13:16 |
Source code size: | 591 bytes / 19 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 207 / 298 |
Referenced in: | [show references] |