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).

1  
sclass mapI_It extends IterableIterator {
2  
  O f;
3  
  Iterator i;
4  
  
5  
  *() {}
6  
  *(O *f, Iterator *i) {}
7  
  
8  
  public bool hasNext() {
9  
    ret i.hasNext();
10  
  }
11  
  
12  
  public O next() {
13  
    ret callF(f, i.next());
14  
  }
15  
  
16  
  toString {
17  
    ret formatFunctionCall('mapI, f, i);
18  
  }
19  
}
20  
21  
22  
// apply a function to an iterator
23  
static IterableIterator lambdaMapLike mapI(final O f, final Iterator i) {
24  
  ret mapI_It(f, i);
25  
}
26  
27  
ifclass IterableIterator
28  
static IterableIterator mapI(IterableIterator i, O f) {
29  
  ret mapI((Iterator) i, f);
30  
}
31  
32  
static IterableIterator mapI(O f, IterableIterator i) {
33  
  ret mapI((Iterator) i, f);
34  
}
35  
endif
36  
37  
static IterableIterator mapI(Iterator i, O f) {
38  
  ret mapI(f, i);
39  
}
40  
41  
static <A, B> ItIt<B> mapI(Iterable<A> i, IF1<A, B> f) {
42  
  ret new MapI(f, iterator(i));
43  
}
44  
45  
static <A, B> ItIt<B> mapI(Iterator<A> i, IF1<A, B> f) {
46  
  ret new MapI(f, i);
47  
}
48  
49  
static <A, B> ItIt<B> mapI(ItIt<A> i, IF1<A, B> f) {
50  
  ret new MapI(f, i);
51  
}
52  
53  
static <A, B> ItIt<B> mapI(IF1<A, B> f, Iterable<A> i) {
54  
  ret new MapI(f, iterator(i));
55  
}
56  
57  
static IterableIterator mapI(Iterable i, O f) {
58  
  ret mapI(f, i.iterator());
59  
}
60  
61  
static IterableIterator mapI(O f, Iterable i) {
62  
  ret mapI(i, f);
63  
}

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: 732 / 844
Version history: 15 change(s)
Referenced in: [show references]