Libraryless. Click here for Pure Java version (1888L/12K).
static L map(Iterable l, O f) { ret map(f, l); } static L map(O f, Iterable l) { L x = emptyList(l); if (l != null) for (O o : l) x.add(callF(f, o)); ret x; } ifclass F1 static <A, B> L<B> map(Iterable<A> l, F1<A, B> f) { ret map(f, l); } static <A, B> L<B> map(F1<A, B> f, Iterable<A> l) { L x = emptyList(l); if (l != null) for (A o : l) x.add(callF(f, o)); ret x; } endif static <A, B> L<B> map(IF1<A, B> f, Iterable<A> l) { ret map(l, f); } static <A, B> L<B> map(Iterable<A> l, IF1<A, B> f) { L x = emptyList(l); if (l != null) for (A o : l) x.add(f.get(o)); ret x; } static <A, B> L<B> map(IF1<A, B> f, A[] l) { ret map(l, f); } static <A, B> L<B> map(A[] l, IF1<A, B> f) { L x = emptyList(l); if (l != null) for (A o : l) x.add(f.get(o)); ret x; } static L map(O f, O[] l) { ret map(f, asList(l)); } static L map(O[] l, O f) { ret map(f, l); } static L map(O f, Map map) { ret map(map, f); } // map: func(key, value) -> list element static L map(Map map, O f) { new L x; if (map != null) for (O _e : map.entrySet()) { Map.Entry e = (Map.Entry) _e; x.add(callF(f, e.getKey(), e.getValue())); } ret x; } static <A, B, C> L<C> map(Map<A, B> map, IF2<A, B, C> f) { ret map(map, (O) f); }
download show line numbers debug dex
Travelled to 19 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, jcllbfdqhrgy, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, podlckwnjdmb, pyentgdyhuwx, pzhvpgtvlbxg, snaazhdonpnp, tslmcundralx, tvejysmllsmz, whxojlpjdney, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1003239 |
Snippet name: | map - call function on list (takes function name, Runnable or function object with "get" method) / now also works on maps |
Eternal ID of this version: | #1003239/17 |
Text MD5: | ade73761de2be1e91aa10b5f848a68e4 |
Transpilation MD5: | 809a3651a2f985635957c503bbf5e378 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-08-25 19:38:05 |
Source code size: | 1332 bytes / 56 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 683 / 803 |
Version history: | 16 change(s) |
Referenced in: | [show references] |
Formerly at http://tinybrain.de/1003239 & http://1003239.tinybrain.de