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

21
LINES

< > BotCompany Repo | #1006407 - firstThat - find first element in list that matches a predicate

JavaX fragment (include)

1  
static <A> A firstThat(Iterable<A> l, O pred) {
2  
  if (l != null) for (A a : l)
3  
    if (checkCondition(pred, a))
4  
      ret a;
5  
  null;
6  
}
7  
8  
static <A> A firstThat(A[] l, IF1<A, Bool> pred) {
9  
  if (l != null) for (A a : l)
10  
    if (pred.get(a))
11  
      ret a;
12  
  null;
13  
}
14  
15  
static <A> A firstThat(Iterable<A> l, IF1<A, Bool> pred) {
16  
  ret firstThat(l, (O) pred);
17  
}
18  
19  
static <A> A lambdaMapLike firstThat(IF1<A, Bool> pred, Iterable<A> l) {
20  
  ret firstThat(l, pred);
21  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xrpafgyirdlv

No comments. add comment

Snippet ID: #1006407
Snippet name: firstThat - find first element in list that matches a predicate
Eternal ID of this version: #1006407/8
Text MD5: ad37c38a2f3f772d5edfdf9cceab8951
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-14 17:22:03
Source code size: 475 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 381 / 406
Version history: 7 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1006407 & http://1006407.tinybrain.de