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

18
LINES

< > BotCompany Repo | #1020170 // combineToJavaTokPattern - also checks N tokens

JavaX fragment (include)

sS combineToJavaTokPattern(S a, S b) {
  if (a == null || b == null) null;
  L<S> tok1 = javaTok(a);
  L<S> tok2 = javaTok(b);
  if (l(tok1) != l(tok2)) null;
  new L<S> out;
  for i over tok1: {
    S t = tok1.get(i);
    bool eq = eq(t, tok2.get(i));
    if (even(i) && !eq) null; // N tokens must be equal
    out.add(eq ? t : "*");
  }
  ret join(out);
}

sS combineToJavaTokPattern(LS l) {
  ret foldl_noSeed(func(S a, S b) -> S { combineToJavaTokPattern(a, b) }, l);
}

Author comment

Began life as a copy of #1017024

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1020170
Snippet name: combineToJavaTokPattern - also checks N tokens
Eternal ID of this version: #1020170/2
Text MD5: 03a4eedccf3a8374bfafe970d6bff09d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-09 19:45:35
Source code size: 491 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 274 / 316
Version history: 1 change(s)
Referenced in: [show references]