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)

1  
sS combineToJavaTokPattern(S a, S b) {
2  
  if (a == null || b == null) null;
3  
  L<S> tok1 = javaTok(a);
4  
  L<S> tok2 = javaTok(b);
5  
  if (l(tok1) != l(tok2)) null;
6  
  new L<S> out;
7  
  for i over tok1: {
8  
    S t = tok1.get(i);
9  
    bool eq = eq(t, tok2.get(i));
10  
    if (even(i) && !eq) null; // N tokens must be equal
11  
    out.add(eq ? t : "*");
12  
  }
13  
  ret join(out);
14  
}
15  
16  
sS combineToJavaTokPattern(LS l) {
17  
  ret foldl_noSeed(func(S a, S b) -> S { combineToJavaTokPattern(a, b) }, l);
18  
}

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: 277 / 320
Version history: 1 change(s)
Referenced in: [show references]