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

11
LINES

< > BotCompany Repo | #1033043 // intersperse_dyn - add an element between each two elements calculated out of them

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

Libraryless. Click here for Pure Java version (3877L/22K).

1  
static <A> L<A> intersperse_dyn(IF2<A> f, Iterable<A> l) {
2  
  new L<A> out;
3  
  A prev = null;
4  
  fOr (A x : l) {
5  
    if (!empty(out))
6  
      out.add(f.get(prev, x));
7  
    out.add(x);
8  
    prev = x;
9  
  }
10  
  ret out;
11  
}

Author comment

Began life as a copy of #1025665

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1033043
Snippet name: intersperse_dyn - add an element between each two elements calculated out of them
Eternal ID of this version: #1033043/1
Text MD5: 4be18eb5d67cbd5adf87de2851b2f64e
Transpilation MD5: b549c926461ccac862ae61d1f2d5581d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-11 17:41:13
Source code size: 218 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 157 / 196
Referenced in: [show references]