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

22
LINES

< > BotCompany Repo | #1009585 - filterMap - 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> filterMap(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> filterMap(O f, Map<A, B> map) {
  ret filterMap(map, f);
}

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

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

Author comment

Began life as a copy of #1008064

download  show line numbers  debug dex   

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

No comments. add comment

Snippet ID: #1009585
Snippet name: filterMap - filter map by func(A, B) -> Bool
Eternal ID of this version: #1009585/8
Text MD5: 5df89ac125d6fe834f00c558885b8350
Transpilation MD5: 35a072b73532decf847d07a7c4423887
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:26:27
Source code size: 551 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 314 / 342
Version history: 7 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1009585 & http://1009585.tinybrain.de