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

22
LINES

< > BotCompany Repo | #1024711 // filterListByPredicateOnIndex

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

Libraryless. Click here for Pure Java version (9184L/51K).

// old syntax
static <A> L<A> filterListByPredicateOnIndex(O pred, L<A> l) {
  new L<A> out;
  int n = l(l);
  for i to n:
    if (isTrue_callF(pred, i))
      out.add(l.get(i));
  ret out;
}

static <A> L<A> lambdaMapLike filterListByPredicateOnIndex(IIntPred pred, L<A> l) {
  new L<A> out;
  int n = l(l);
  for i to n:
    if (pred.get(i))
      out.add(l.get(i));
  ret out;
}

static <A> L<A> filterListByPredicateOnIndex(L<A> l, IIntPred pred) {
  ret filterListByPredicateOnIndex(pred, l);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024711
Snippet name: filterListByPredicateOnIndex
Eternal ID of this version: #1024711/4
Text MD5: 1f16180f92695ff0d273e9524842da75
Transpilation MD5: 149065f0358f6b50e4911e3c88eac2d2
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-08-05 18:36:52
Source code size: 522 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 200 / 293
Version history: 3 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1024713 - filterAntiFilterListByPredicateOnIndex