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

21
LINES

< > BotCompany Repo | #1033231 // firstThatNot - find first element in list that doesn't match a predicate

JavaX fragment (include)

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

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

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

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

Author comment

Began life as a copy of #1006407

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033231
Snippet name: firstThatNot - find first element in list that doesn't match a predicate
Eternal ID of this version: #1033231/1
Text MD5: fb18ed88d11c494f4043edc3c36d8c6d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-16 07:30:23
Source code size: 468 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 196 / 224
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)