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

7
LINES

< > BotCompany Repo | #1030680 // lastIndexOfPred - index of last element in list that matches a predicate

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

Libraryless. Click here for Pure Java version (2709L/16K).

static <A> int lastIndexOfPred(L<A> l, IF1<A, Bool> pred) {
  if (l == null) ret -1;
  for (int i = l(l)-1; i >= 0; i--)
    if (pred.get(l.get(i)))
      ret i;
  ret -1;
}

Author comment

Began life as a copy of #1006686

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030680
Snippet name: lastIndexOfPred - index of last element in list that matches a predicate
Eternal ID of this version: #1030680/4
Text MD5: 9dacbb265b5ed161d3a61b4361ddc952
Transpilation MD5: 5ed5df2a44e3a31623f954ecca66ba98
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-03-03 23:54:15
Source code size: 179 bytes / 7 lines
Pitched / IR pitched: No / No
Views / Downloads: 225 / 275
Version history: 3 change(s)
Referenced in: [show references]