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

8
LINES

< > BotCompany Repo | #1025665 // intersperse - add an element between each two elements

JavaX fragment (include)

static <A> L<A> intersperse(A a, Iterable<A> l) {
  new L<A> out;
  fOr (A x : l) {
    if (!empty(out)) out.add(a);
    out.add(x);
  }
  ret out;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1025665
Snippet name: intersperse - add an element between each two elements
Eternal ID of this version: #1025665/1
Text MD5: 05677b57a56b586458a225f38ef9bdb4
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-10-12 18:43:45
Source code size: 156 bytes / 8 lines
Pitched / IR pitched: No / No
Views / Downloads: 223 / 244
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1033043 - intersperse_dyn - add an element between each two elements calculated out of them
#1036550 - intersperseF - add a function result between each two elements