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

41
LINES

< > BotCompany Repo | #1019625 // mapNonNulls - map, then nonNulls

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

Libraryless. Click here for Pure Java version (2165L/14K).

static L mapNonNulls(Iterable l, O f) { ret mapNonNulls(f, l); }

static L lambdaMapLike mapNonNulls(O f, Iterable l) {
  new L x;
  if (l != null) for (O o : l)
    addIfNotNull(x, callF(f, o));
  ret x;
}

static L mapNonNulls(O f, O[] l) {
  new L x;
  if (l != null) for (O o : l)
    addIfNotNull(x, callF(f, o));
  ret x;
}

ifclass F1
  static <A, B> L<B> mapNonNulls(Iterable<A> l, F1<A, B> f) { ret mapNonNulls(f, l); }

  static <A, B> L<B> mapNonNulls(F1<A, B> f, Iterable<A> l) {
    new L x;
    if (l != null) for (O o : l)
      addIfNotNull(x, callF(f, o));
    ret x;
  }
endif

static <A, B> L<B> mapNonNulls(A[] l, IF1<A, B> f) {
  ret mapNonNulls(f, l);
}

static <A, B> L<B> mapNonNulls(Iterable<A> l, IF1<A, B> f) {
  L x = emptyList(l);
  if (l != null) for (A o : l)
    addIfNotNull(x, f.get(o));
  ret x;
}

static <A, B> L<B> mapNonNulls(IF1<A, B> f, Iterable<A> l) {
  ret mapNonNulls(l, f);
}

Author comment

Began life as a copy of #1003239

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1019625
Snippet name: mapNonNulls - map, then nonNulls
Eternal ID of this version: #1019625/8
Text MD5: 7169ae44d27062a49a3797406e8ebe44
Transpilation MD5: 432c4c04399eb8bc2f22823321be666f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-11-01 13:09:31
Source code size: 961 bytes / 41 lines
Pitched / IR pitched: No / No
Views / Downloads: 316 / 441
Version history: 7 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)