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

10
LINES

< > BotCompany Repo | #1006686 // indexOfPred - index of first element in list that matches a predicate

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (1691L/11K).

1  
static int indexOfPred(L l, O pred) {
2  
  for i over l:
3  
    if (checkCondition(pred, l.get(i)))
4  
      ret i;
5  
  ret -1;
6  
}
7  
8  
static <A, B> int indexOfPred(L<A> l, IF1<A, B> pred) {
9  
  ret indexOfPred(l, (O) pred);
10  
}

Author comment

Began life as a copy of #1006407

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006686
Snippet name: indexOfPred - index of first element in list that matches a predicate
Eternal ID of this version: #1006686/3
Text MD5: 12b19b548619daa0fec48d8fb326f9b4
Transpilation MD5: dcc43138e70cf8bb51eb71029c23c392
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-07 23:42:37
Source code size: 218 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 567 / 682
Version history: 2 change(s)
Referenced in: [show references]