Libraryless. Click here for Pure Java version (360L/2K).
1 | static L flattenCollectionsAndArrays(Iterable a) { |
2 | new L l; |
3 | for (O x : a) |
4 | if (x cast Cl) |
5 | l.addAll(flattenCollectionsAndArrays(x)); |
6 | else if (x cast O[]) |
7 | l.addAll(flattenCollectionsAndArrays(asList(x))); |
8 | else |
9 | l.add(x); |
10 | ret l; |
11 | } |
12 | |
13 | static L flattenCollectionsAndArrays(O... whatever) { |
14 | ret flattenCollectionsAndArrays(ll(whatever)); |
15 | } |
Began life as a copy of #1032754
download show line numbers debug dex old transpilations
Travelled to 5 computer(s): bhatertpkbcr, ekrmjmnbrukm, elmgxqgtpvxh, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033135 |
Snippet name: | flattenCollectionsAndArrays |
Eternal ID of this version: | #1033135/5 |
Text MD5: | 1a385d8eddcce2e6f80ea654ed0c0e6a |
Transpilation MD5: | 1edb772020247684ede3293f8185688f |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-08-12 00:56:57 |
Source code size: | 381 bytes / 15 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 168 / 271 |
Version history: | 4 change(s) |
Referenced in: | [show references] |