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

16
LINES

< > BotCompany Repo | #1014381 // commonPrefixCI

JavaX fragment (include)

1  
static S commonSuffixCI(S a, S b) {
2  
  int i = 0, nb = b.length(), na = a.length(), n = min(na, nb);
3  
  while (i < n && eqic(a.charAt(na-1-i), b.charAt(nb-1-i)))
4  
    ++i;
5  
  return i == nb ? b : substring(a, na-i);
6  
}
7  
8  
static S commonSuffixCI(L<S> l) {
9  
  if (empty(l)) ret "";
10  
  S s = first(l);
11  
  for (int i = 1; i < l(l); i++) {
12  
    if (empty(s)) ret s;
13  
    s = commonSuffixCI(s, l.get(i));
14  
  }
15  
  ret s;
16  
}

Author comment

Began life as a copy of #1014380

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1014381
Snippet name: commonPrefixCI
Eternal ID of this version: #1014381/1
Text MD5: 62136beacd2256ff3e324e738322d137
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-04-20 17:34:35
Source code size: 417 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 366 / 414
Referenced in: [show references]