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).

static <A, B> Map<A, B> antiFilterMap(Map<A, B> map, O f) {
  if (map == null) null;
  Map<A, B> m2 = similarEmptyMap(map);
  for (A a : keys(map)) {
    B b = map.get(a);
    if (!isTrue(callF(f, a, b)))
      m2.put(a, b);
  }
  ret m2;
}

static <A, B> Map<A, B> antiFilterMap(O f, Map<A, B> map) {
  ret antiFilterMap(map, f);
}

static <A, B> Map<A, B> antiFilterMap(Map<A, B> map, IF2<A, B, Bool> f) {
  ret antiFilterMap(f, map);
}

static <A, B> Map<A, B> curry1Like antiFilterMap(IF2<A, B, Bool> f, Map<A, B> map) {
  ret antiFilterMap(map, (O) f);
}

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: 109 / 161
Referenced in: [show references]