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

20
LINES

< > BotCompany Repo | #1024294 // mapToMap - map a list to a Map using a function returning a pair; also synonym of mapMapToMap

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

Transpiled version (3909L) is out of date.

static <A, B, C> Map<B, C> lambdaMapLike mapToMap(IF1<A, Pair<B, C>> f, Iterable<A> l) {
  new Map<B, C> map;
  fOr (A o : l) {
    Pair<B, C> p = f.get(o);
    map.put(p.a, p.b);
  }
  ret map;
}

static <A, B, C> Map<B, C> mapToMap(Iterable<A> l, IF1<A, Pair<B, C>> f) {
  ret mapToMap(f, l);
}

static <A, B, C, D> Map<C, D> mapToMap(Map<A, B> m, IF2<A, B, Pair<C, D>> f) {
  ret mapMapToMap(f, m);
}

static <A, B, C, D> Map<C, D> mapToMap(IF2<A, B, Pair<C, D>> f, Map<A, B> m) {
  ret mapMapToMap(f, m);
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1024294
Snippet name: mapToMap - map a list to a Map using a function returning a pair; also synonym of mapMapToMap
Eternal ID of this version: #1024294/11
Text MD5: 63e95eccb9d5192c757b039065f24085
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-12-30 19:44:05
Source code size: 529 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 349 / 494
Version history: 10 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1024295 - mapToOrderedMap
#1025202 - mapMapToMap - map a Map to a similar type Map using a function taking two arguments and returning a pair
#1029675 - mapToCIMap - map a list to a ciMap using a function returning a pair
#1030227 - safeMapToMap - safe version to mapToMap
#1031781 - mapToWeakHashMap
#1032620 - mapToMap_pcall - mapToMap + pcall