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

1  
sbool match3_withInts(S pat, S s, Matches m default null) {
2  
  LS tokPat = javaTokWithAllPlusAngleBrackets(pat);
3  
  S pat2 = join(replace(cloneList(tokPat), "<int>", "*"));
4  
  Matches m2 = m == null ? new Matches : m;
5  
  ifdef match3_withInts_debug
6  
    printVars_str match3_withInts(+pat2, +s);
7  
  endifdef
8  
  if (!match3(pat2, s, m2)) false;
9  
  LS vars = filter(codeTokens(tokPat), t -> eqOneOf(t, "<int>", "*"));
10  
  ifdef match3_withInts_debug
11  
    printVars_str match3_withInts(+m2, +vars);
12  
  endifdef
13  
  for i over vars: {
14  
    if (eq(vars.get(i), "<int>") && !isInteger(m2.get(i)))
15  
      false;
16  
  }
17  
  true;
18  
}

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: 87 / 141
Version history: 4 change(s)
Referenced in: [show references]