// themap is the replacement map in list form - in/out/in/out/... static S mapBasedReplace(L<S> themap, S s) { L<S> tok = javaTok(s); for (int i = 1; i < l(tok); i += 2) { for (int j = 0; j < l(themap); j += 2) { S x = themap.get(j), y = themap.get(j+1); L<S> tokx = javaTok(x), toky = javaTok(y); mapBasedReplace_matchReplace(tok, i, tokx, toky); } } ret join(tok); } static void mapBasedReplace_matchReplace(L<S> tok, int i, L<S> tokx, L<S> toky) { if (tokRegionMatchIC(tok, i, tokx)) { clearAllTokens(tok.subList(i, i+l(tokx)-2)); tok.set(i, join(toky)); } }
Began life as a copy of #1002187
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: | #1002188 |
Snippet name: | mapBasedReplace |
Eternal ID of this version: | #1002188/1 |
Text MD5: | 71cd16b9e64c9fe17deb379efd437dfe |
Author: | stefan |
Category: | nl |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-12-24 00:27:54 |
Source code size: | 628 bytes / 19 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 687 / 895 |
Referenced in: | #1002427 - Accellerating 629 (SPIKE) #1006654 - Standard functions list 2 (LIVE, continuation of #761) #3000382 - Answer for ferdie (>> t = 1, f = 0) #3000383 - Answer for funkoverflow (>> t=1, f=0 okay) |