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

50
LINES

< > BotCompany Repo | #1003524 // filter

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

Transpiled version (2188L) is out of date.

1  
static <A> L<A> filter(Iterable<A> c, O pred) {
2  
  if (pred instanceof F1) ret filter(c, (F1<A, Bool>) pred);
3  
4  
  ifdef filter_debug
5  
    print("Slow filter called");
6  
  endifdef
7  
  new L x;
8  
  if (c != null) for (O o : c)
9  
    if (isTrue(callF(pred, o)))
10  
      x.add(o);
11  
  ret x;
12  
}
13  
14  
static L filter(O pred, Iterable c) {
15  
  ret filter(c, pred);
16  
}
17  
18  
static <A, B extends A> L<B> filter(Iterable<B> c, F1<A, Bool> pred) {
19  
  new L x;
20  
  if (c != null) for (B o : c)
21  
    if (pred.get(o))
22  
      x.add(o);
23  
  ret x;
24  
}
25  
26  
static <A, B extends A> L<B> filter(F1<A, Bool> pred, Iterable<B> c) {
27  
  ret filter(c, pred);
28  
}
29  
30  
//ifclass IF1
31  
static <A, B extends A> L<B> filter(Iterable<B> c, IF1<A, Bool> pred) {
32  
  new L x;
33  
  if (c != null) for (B o : c)
34  
    if (pred.get(o))
35  
      x.add(o);
36  
  ret x;
37  
}
38  
39  
static <A, B extends A> L<B> filter(B[] c, IF1<A, Bool> pred) {
40  
  new L x;
41  
  if (c != null) for (B o : c)
42  
    if (pred.get(o))
43  
      x.add(o);
44  
  ret x;
45  
}
46  
47  
static <A, B extends A> L<B> lambdaMapLike filter(IF1<A, Bool> pred, Iterable<B> c) {
48  
  ret filter(c, pred);
49  
}
50  
//endif

download  show line numbers  debug dex  old transpilations   

Travelled to 19 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, dpqxeycirhfy, ekrmjmnbrukm, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, qsqiayxyrbia, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xrpafgyirdlv

No comments. add comment

Snippet ID: #1003524
Snippet name: filter
Eternal ID of this version: #1003524/14
Text MD5: 6e1397387b45c2d0486067a06b4d39e6
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-06-16 01:47:27
Source code size: 1099 bytes / 50 lines
Pitched / IR pitched: No / No
Views / Downloads: 781 / 1018
Version history: 13 change(s)
Referenced in: [show references]