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

63
LINES

< > BotCompany Repo | #1004292 // mapI - apply a function to an iterator

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

Libraryless. Click here for Pure Java version (7601L/43K).

sclass mapI_It extends IterableIterator {
  O f;
  Iterator i;
  
  *() {}
  *(O *f, Iterator *i) {}
  
  public bool hasNext() {
    ret i.hasNext();
  }
  
  public O next() {
    ret callF(f, i.next());
  }
  
  toString {
    ret formatFunctionCall('mapI, f, i);
  }
}


// apply a function to an iterator
static IterableIterator lambdaMapLike mapI(final O f, final Iterator i) {
  ret mapI_It(f, i);
}

ifclass IterableIterator
static IterableIterator mapI(IterableIterator i, O f) {
  ret mapI((Iterator) i, f);
}

static IterableIterator mapI(O f, IterableIterator i) {
  ret mapI((Iterator) i, f);
}
endif

static IterableIterator mapI(Iterator i, O f) {
  ret mapI(f, i);
}

static <A, B> ItIt<B> mapI(Iterable<A> i, IF1<A, B> f) {
  ret new MapI(f, iterator(i));
}

static <A, B> ItIt<B> mapI(Iterator<A> i, IF1<A, B> f) {
  ret new MapI(f, i);
}

static <A, B> ItIt<B> mapI(ItIt<A> i, IF1<A, B> f) {
  ret new MapI(f, i);
}

static <A, B> ItIt<B> mapI(IF1<A, B> f, Iterable<A> i) {
  ret new MapI(f, iterator(i));
}

static IterableIterator mapI(Iterable i, O f) {
  ret mapI(f, i.iterator());
}

static IterableIterator mapI(O f, Iterable i) {
  ret mapI(i, f);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xrpafgyirdlv

No comments. add comment

Snippet ID: #1004292
Snippet name: mapI - apply a function to an iterator
Eternal ID of this version: #1004292/16
Text MD5: 97d827120c30814f4e8a534654249085
Transpilation MD5: a6c598efea20e1db63240d373e98745d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-30 01:36:06
Source code size: 1239 bytes / 63 lines
Pitched / IR pitched: No / No
Views / Downloads: 650 / 742
Version history: 15 change(s)
Referenced in: [show references]