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

15
LINES

< > BotCompany Repo | #1033135 // flattenCollectionsAndArrays

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

Libraryless. Click here for Pure Java version (360L/2K).

static L flattenCollectionsAndArrays(Iterable a) {
  new L l;
  for (O x : a)
    if (x cast Cl)
      l.addAll(flattenCollectionsAndArrays(x));
    else if (x cast O[])
      l.addAll(flattenCollectionsAndArrays(asList(x)));
    else
      l.add(x);
  ret l;
}

static L flattenCollectionsAndArrays(O... whatever) {
  ret flattenCollectionsAndArrays(ll(whatever));
}

Author comment

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: 102 / 184
Version history: 4 change(s)
Referenced in: [show references]