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

26
LINES

< > BotCompany Repo | #1012440 // iteratorFromFunction_f0 - ends on null

JavaX fragment (include)

static <A> IterableIterator<A> iteratorFromFunction_f0(final F0<A> f) {
  class IFF2 extends IterableIterator<A> {
    A a;
    bool done;
    
    public bool hasNext() {
      getNext();
      ret !done;
    }
    
    public A next() {
      getNext();
      if (done) fail();
      A _a = a;
      a = null;
      ret _a;
    }
    
    void getNext() {
      if (done || a != null) ret;
      a = f.get();
      done = a == null;
    }
  };
  ret new IFF2;
}

Author comment

Began life as a copy of #1006726

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1012440
Snippet name: iteratorFromFunction_f0 - ends on null
Eternal ID of this version: #1012440/3
Text MD5: 51477e747893ff2cdcb5e12b0ada6ef2
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-28 19:40:51
Source code size: 488 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 411 / 410
Version history: 2 change(s)
Referenced in: [show references]