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

23
LINES

< > BotCompany Repo | #1002135 // indexOfSubList

JavaX fragment (include)

1  
static <A> int indexOfSubList(L<A> x, L<A> y) {
2  
  ret indexOfSubList(x, y, 0);
3  
}
4  
5  
static <A> int indexOfSubList(L<A> x, L<A> y, int i) {
6  
  outer: for (; i+l(y) <= l(x); i++) {
7  
    for (int j = 0; j < l(y); j++)
8  
      if (neq(x.get(i+j), y.get(j)))
9  
        continue outer;
10  
    ret i;
11  
  }
12  
  ret -1;
13  
}
14  
15  
static <A> int indexOfSubList(L<A> x, A[] y, int i) {
16  
  outer: for (; i+l(y) <= l(x); i++) {
17  
    for (int j = 0; j < l(y); j++)
18  
      if (neq(x.get(i+j), y[j]))
19  
        continue outer;
20  
    ret i;
21  
  }
22  
  ret -1;
23  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1002135
Snippet name: indexOfSubList
Eternal ID of this version: #1002135/2
Text MD5: 8a6b4117739d0611074e3d34e07179bc
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-04-13 18:05:23
Source code size: 533 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 750 / 2257
Version history: 1 change(s)
Referenced in: [show references]