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

8
LINES

< > BotCompany Repo | #1015352 // iota (like in APL) - count from 1 to n (iterator)

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

Libraryless. Click here for Pure Java version (57L/1K).

static IterableIterator<Int> iota(final int n) {
  ret new IterableIterator<Int>() {
    int i = 0;
    
    public bool hasNext() { ret i < n; }
    public Int next() { ret ++i; }
  };
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1015352
Snippet name: iota (like in APL) - count from 1 to n (iterator)
Eternal ID of this version: #1015352/2
Text MD5: 4b5b1c6fa09083b74801ebcf30ea875c
Transpilation MD5: 72247defeaf6834713e134aaef1e2f2c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-09-02 13:48:42
Source code size: 194 bytes / 8 lines
Pitched / IR pitched: No / No
Views / Downloads: 510 / 624
Version history: 1 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1018109 - countIterator_exclusive - count from a to b (exclusively)
#1020977 - iotaList (like in APL) - (virtual) list from 1 to n
#1024817 - floatIota - iterator of floats in range with defined step
#1027215 - iota_zero - count from 0 to n-1 (iterator)