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

11
LINES

< > BotCompany Repo | #1029092 // iterateListWithIndex

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

Libraryless. Click here for Pure Java version (5100L/28K).

1  
static <A> ItIt<Pair<Int, A>> iterateListWithIndex(Iterable<A> l, int startAt default 0) {
2  
  ret iff(new O {
3  
    Iterator it = iterator(l);
4  
    int i = startAt;
5  
    
6  
    public O get() {
7  
      if (!it.hasNext()) ret endMarker();
8  
      ret pair(i++, it.next());
9  
    }
10  
  });
11  
}

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: #1029092
Snippet name: iterateListWithIndex
Eternal ID of this version: #1029092/8
Text MD5: fe23756f0ff219404c18ba1f2e1138a3
Transpilation MD5: 215146ddd0215c89c1c5429baad9b637
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-08 05:32:19
Source code size: 284 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 197 / 295
Version history: 7 change(s)
Referenced in: [show references]