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

27
LINES

< > BotCompany Repo | #1010000 // map_pcall - map() with safe calling (skip elements when failed)

JavaX fragment (include)

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

static L map_pcall(O f, Iterable l) {
  new L x;
  for (O o : unnull(l)) pcall { x.add(callF(f, o)); }
  ret x;
}

static L map_pcall(O f, O[] l) {
  new L x;
  for (O o : unnull(l)) pcall { x.add(callF(f, o)); }
  ret x;
}

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

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

Author comment

Began life as a copy of #1003239

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1010000
Snippet name: map_pcall - map() with safe calling (skip elements when failed)
Eternal ID of this version: #1010000/4
Text MD5: d31adc103e120f77b0395c1cb236c3bd
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-25 12:57:18
Source code size: 555 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 378 / 446
Version history: 3 change(s)
Referenced in: [show references]