Libraryless. Click here for Pure Java version (5266L/29K).
1 | static <A> O[] mapToArrayOrNull(A[] l, IF1<A, O> f) { |
2 | if (l == null) null; |
3 | int n = l.length; |
4 | if (n == 0) null; |
5 | O[] array = new[n]; |
6 | for i to n: |
7 | array[i] = f.get(l[i]); |
8 | ret array; |
9 | } |
10 | |
11 | static <A> O[] lambdaMapLike mapToArrayOrNull(IF1<A, O> f, A[] l) { |
12 | ret mapToArrayOrNull(l, f); |
13 | } |
14 | |
15 | static <A> O[] mapToArrayOrNull(IF1<A, O> f, Cl<A> l) { |
16 | int n = l(l); |
17 | if (n == 0) null; |
18 | O[] array = new[n]; |
19 | if (n != 0) { |
20 | Iterator it = iterator(l); |
21 | for i to n: |
22 | array[i] = callF(f, it.next()); |
23 | } |
24 | ret array; |
25 | } |
26 | |
27 | static <A> O[] mapToArrayOrNull(Cl<A> l, IF1<A, O> f) { |
28 | ret mapToArrayOrNull(l, f); |
29 | } |
Began life as a copy of #1006543
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034772 |
Snippet name: | mapToArrayOrNull |
Eternal ID of this version: | #1034772/4 |
Text MD5: | e8ae1eaa46f0c442574da11350aac45e |
Transpilation MD5: | ada5490fcd6341d8362f5f98842822ff |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-03-08 07:29:02 |
Source code size: | 650 bytes / 29 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 144 / 216 |
Version history: | 3 change(s) |
Referenced in: | [show references] |