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

15
LINES

< > BotCompany Repo | #1026424 // overlappingPairs_lazy - lazy version of overlappingPairs

JavaX fragment (include)

static <A> LPair<A> overlappingPairs_lazy(L<A> l) {
  if (l == null) null;
  
  class OverlappingPairs extends LazyList<Pair<A>> {
    final int n = max(0, l(l)-1);
    
    public int size() { ret n; }
    
    public Pair<A> get(int i) {
      ret pair(l.get(i), l.get(i+1));
    }
  }
  
  ret new OverlappingPairs;
}

Author comment

Began life as a copy of #1014575

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1026424
Snippet name: overlappingPairs_lazy - lazy version of overlappingPairs
Eternal ID of this version: #1026424/4
Text MD5: 4035de07069cf32cc0ec73864c81164f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-01-03 17:57:54
Source code size: 334 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 239 / 266
Version history: 3 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)