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

22
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 (3154L/18K).

// TODO: old syntax, get rid of
static <A> A firstThat(Iterable<A> l, O pred) {
  if (l != null) for (A a : l)
    if (checkCondition(pred, a))
      ret a;
  null;
}

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

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

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

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/9
Text MD5: bdc4f00ea29c3eacf877643f2a6fc40e
Transpilation MD5: 5fcf56336308cad0d9be37adb05457d2
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-09-03 01:25:13
Source code size: 508 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 393 / 423
Version history: 8 change(s)
Referenced in: #1006654 #1006686 #1006887 #1021565

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