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

21
LINES

< > BotCompany Repo | #1004652 - mapValues - apply function to a map's values

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

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

static Map mapValues(O func, Map map) {
  Map m = similarEmptyMap(map);
  for (O key : keys(map))
    m.put(key, callF(func, map.get(key)));
  ret m;
}

static <A, B, C> Map<A, C> mapValues(Map<A, B> map, IF1<B, C> f) {
  ret mapValues(f, map);
}

static <A, B, C> Map<A, C> lambdaMapLike mapValues(IF1<B, C> f, Map<A, B> map) {
  Map m = similarEmptyMap(map);
  for (A key, B val : map)
    m.put(key, f.get(val));
  ret m;
}

static Map mapValues(Map map, O func) {
  ret mapValues(func, map);
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1004652
Snippet name: mapValues - apply function to a map's values
Eternal ID of this version: #1004652/9
Text MD5: 2a0336c19d4ec01579a3f4271ab211fa
Transpilation MD5: b07c77ee7b5ccf103d7b96a6b177ceda
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-04-26 18:10:27
Source code size: 517 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 483 / 543
Version history: 8 change(s)
Referenced in: [show references]