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

18
LINES

< > BotCompany Repo | #1030933 // match3_withInts - understands "*" and "<int>"

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

Libraryless. Click here for Pure Java version (3398L/20K).

sbool match3_withInts(S pat, S s, Matches m default null) {
  LS tokPat = javaTokWithAllPlusAngleBrackets(pat);
  S pat2 = join(replace(cloneList(tokPat), "<int>", "*"));
  Matches m2 = m == null ? new Matches : m;
  ifdef match3_withInts_debug
    printVars_str match3_withInts(+pat2, +s);
  endifdef
  if (!match3(pat2, s, m2)) false;
  LS vars = filter(codeTokens(tokPat), t -> eqOneOf(t, "<int>", "*"));
  ifdef match3_withInts_debug
    printVars_str match3_withInts(+m2, +vars);
  endifdef
  for i over vars: {
    if (eq(vars.get(i), "<int>") && !isInteger(m2.get(i)))
      false;
  }
  true;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030933
Snippet name: match3_withInts - understands "*" and "<int>"
Eternal ID of this version: #1030933/5
Text MD5: bb014a4c37393b47b41181b90efa3c6e
Transpilation MD5: 2a9a49d7b79029a86992e0d42cb87cee
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-04-12 17:22:20
Source code size: 619 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 153 / 220
Version history: 4 change(s)
Referenced in: [show references]