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) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3857L/22K).

static <A> A firstThat(Iterable<A> l, IF1<A, Bool> pred) {
  fOr (A a : l)
    if (pred.get(a))
      ret a;
  null;
}

static <A> A firstThat(A[] l, IF1<A, Bool> pred) {
  fOr (A a : l)
    if (pred.get(a))
      ret a;
  null;
}

static <A> A lambdaMapLike firstThat(IF1<A, Bool> pred, Iterable<A> l) {
  ret firstThat(l, pred);
}

static <A> A lambdaMapLike firstThat(IF1<A, Bool> pred, A[] l) {
  ret firstThat(l, pred);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, 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/11
Text MD5: bfefba0caaaf3e5e9334030d483d1af2
Transpilation MD5: 52d0046c62978d42174d1be97302491e
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-10 23:51:31
Source code size: 448 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 411 / 453
Version history: 10 change(s)
Referenced in: [show references]