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.

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

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: 151 / 211
Version history: 5 change(s)
Referenced in: [show references]