Libraryless. Click here for Pure Java version (9550L/54K).
1 | static <A, B> L<B> lambdaMapLike lazilyMap(IF1<A, B> f, L<A> l) { |
2 | ret lazyMap((O) f, l); |
3 | } |
4 | |
5 | static L lazilyMap(fO f, fL l) { |
6 | ret new RandomAccessAbstractList { |
7 | final int size = l(l); |
8 | new HashMap<Int, O> data; |
9 | |
10 | public int size() { ret size; } |
11 | public O get(int i) { |
12 | if (data.containsKey(i)) |
13 | ret data.get(i); |
14 | O o = callF(f, l.get(i)); |
15 | data.put(i, o); |
16 | ret o; |
17 | } |
18 | }; |
19 | } |
20 | |
21 | static <A, B> L<B> lazilyMap(L<A> l, IF1<A, B> f) { |
22 | ret lazilyMap(f, l); |
23 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1018394 |
Snippet name: | lazilyMap - map list to list lazily (calculating elements on demand & then caching them) |
Eternal ID of this version: | #1018394/8 |
Text MD5: | 7b9bbc391eae5e9d8816c014bba1c4cb |
Transpilation MD5: | 59e113851f20ad7db41b50a6edae1eb7 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-06-27 06:18:29 |
Source code size: | 523 bytes / 23 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 404 / 518 |
Version history: | 7 change(s) |
Referenced in: | [show references] |