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

22
LINES

< > BotCompany Repo | #1027743 // antiFilterMap - filter map by func(A, B) -> Bool

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

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

1  
static <A, B> Map<A, B> antiFilterMap(Map<A, B> map, O f) {
2  
  if (map == null) null;
3  
  Map<A, B> m2 = similarEmptyMap(map);
4  
  for (A a : keys(map)) {
5  
    B b = map.get(a);
6  
    if (!isTrue(callF(f, a, b)))
7  
      m2.put(a, b);
8  
  }
9  
  ret m2;
10  
}
11  
12  
static <A, B> Map<A, B> antiFilterMap(O f, Map<A, B> map) {
13  
  ret antiFilterMap(map, f);
14  
}
15  
16  
static <A, B> Map<A, B> antiFilterMap(Map<A, B> map, IF2<A, B, Bool> f) {
17  
  ret antiFilterMap(f, map);
18  
}
19  
20  
static <A, B> Map<A, B> curry1Like antiFilterMap(IF2<A, B, Bool> f, Map<A, B> map) {
21  
  ret antiFilterMap(map, (O) f);
22  
}

Author comment

Began life as a copy of #1009585

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1027743
Snippet name: antiFilterMap - filter map by func(A, B) -> Bool
Eternal ID of this version: #1027743/1
Text MD5: 235193be3cc38f543811aa3e6861f53c
Transpilation MD5: be0ff8cfe9e47ac254ece373b11565ae
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-04-09 22:35:51
Source code size: 580 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 169 / 237
Referenced in: [show references]