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).

sbool flexMatchIC_iterate_debug;
sbool flexMatchIC_iterate_useTokenization = true;

svoid flexMatchIC_iterate(S pat, S input, VF1<Matches> onMatch, O... _) {
  if (flexMatchIC_iterate_debug)
    print("flexMatchIC_iterate " + pat + " / " + input);
  optPar IF1<S, LS> tokenizer = lambda1 javaTokNPunctuation_plusAsterisk;
  flexMatchIC_iterate(pat,
    callTokenizer(tokenizer, pat),
    callTokenizer(tokenizer, input),
    onMatch, _);
}

svoid flexMatchIC_iterate(S pat, LS tokPat, LS tokInput, VF1<Matches> onMatch, O... _) {
  L<Int> varIndices = flexMatchIC_getVarIndices(tokPat, tokInput);
  if (varIndices == null) ret;
  if (flexMatchIC_iterate_debug)
    printStructs(+varIndices, +tokPat, +tokInput);
  ItIt<L<S>> spreadInputs = ai_spreadCertainIndices_2_iterator(tokPat, tokInput, varIndices);
  for (LS tok : spreadInputs) {
    if (flexMatchIC_iterate_debug)
      print("Testing spread " + sfu(codeTokens(tokPat)) + " with input: " + sfu(codeTokens(tok)));
    new Matches m;
    if (flexMatchIC_iterate_useTokenization
      ? match3(tokPat, tok, m)
      : match(pat, tok, m)) {
      if (flexMatchIC_iterate_debug)
        print("Got match: " + m);
      callF(onMatch, m);
    }
  }
}

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: 381 / 490
Version history: 20 change(s)
Referenced in: [show references]