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

13
LINES

< > BotCompany Repo | #1033180 // flattenIterablesAndArrays (we consider Iterators iterable) - strongest flattening function

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

Transpiled version (3797L) is out of date.

1  
static L flattenIterablesAndArrays(Iterable a) {
2  
  new L l;
3  
  for (O x : a)
4  
    if (x cast Iterable)
5  
      l.addAll(flattenIterablesAndArrays(x));
6  
    else if (x cast Iterator)
7  
      l.addAll(flattenIterablesAndArrays(asList(x));
8  
    else if (x cast O[])
9  
      l.addAll(flattenIterablesAndArrays(asList(x)));
10  
    else
11  
      l.add(x);
12  
  ret l;
13  
}

Author comment

Began life as a copy of #1033135

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033180
Snippet name: flattenIterablesAndArrays (we consider Iterators iterable) - strongest flattening function
Eternal ID of this version: #1033180/6
Text MD5: b20162d21cc9cc3edbb5af779e8adf12
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-15 23:43:28
Source code size: 356 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 104 / 141
Version history: 5 change(s)
Referenced in: [show references]