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

32
LINES

< > BotCompany Repo | #1021059 // flexMatchIC_iterate [finds all solutions, seems to work now]

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (5320L/33K).

1  
sbool flexMatchIC_iterate_debug;
2  
sbool flexMatchIC_iterate_useTokenization = true;
3  
4  
svoid flexMatchIC_iterate(S pat, S input, VF1<Matches> onMatch, O... _) {
5  
  if (flexMatchIC_iterate_debug)
6  
    print("flexMatchIC_iterate " + pat + " / " + input);
7  
  optPar IF1<S, LS> tokenizer = lambda1 javaTokNPunctuation_plusAsterisk;
8  
  flexMatchIC_iterate(pat,
9  
    callTokenizer(tokenizer, pat),
10  
    callTokenizer(tokenizer, input),
11  
    onMatch, _);
12  
}
13  
14  
svoid flexMatchIC_iterate(S pat, LS tokPat, LS tokInput, VF1<Matches> onMatch, O... _) {
15  
  L<Int> varIndices = flexMatchIC_getVarIndices(tokPat, tokInput);
16  
  if (varIndices == null) ret;
17  
  if (flexMatchIC_iterate_debug)
18  
    printStructs(+varIndices, +tokPat, +tokInput);
19  
  ItIt<L<S>> spreadInputs = ai_spreadCertainIndices_2_iterator(tokPat, tokInput, varIndices);
20  
  for (LS tok : spreadInputs) {
21  
    if (flexMatchIC_iterate_debug)
22  
      print("Testing spread " + sfu(codeTokens(tokPat)) + " with input: " + sfu(codeTokens(tok)));
23  
    new Matches m;
24  
    if (flexMatchIC_iterate_useTokenization
25  
      ? match3(tokPat, tok, m)
26  
      : match(pat, tok, m)) {
27  
      if (flexMatchIC_iterate_debug)
28  
        print("Got match: " + m);
29  
      callF(onMatch, m);
30  
    }
31  
  }
32  
}

Author comment

Began life as a copy of #1018145

download  show line numbers  debug dex  old transpilations   

Travelled to 9 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1021059
Snippet name: flexMatchIC_iterate [finds all solutions, seems to work now]
Eternal ID of this version: #1021059/21
Text MD5: a20c80be7e89ea6737011eb1431b115f
Transpilation MD5: 93433270ce75d3f2b9becb5ad9925c9f
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-04-21 16:23:15
Source code size: 1234 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 450 / 573
Version history: 20 change(s)
Referenced in: [show references]