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

15
LINES

< > BotCompany Repo | #1036369 // mapOdds - apply function to elements 1, 3 etc

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

Libraryless. Click here for Pure Java version (9707L/53K).

1  
static <A> L<A> mapOdds(L<A> l, IF1<A> f) {
2  
  int n = l(l);
3  
  L<A> out = emptyList(n);
4  
  for i to n: {
5  
    A a = l.get(i);
6  
    if (odd(i))
7  
      a = f.get(a);
8  
    out.add(a);
9  
  }
10  
  ret out;
11  
}
12  
13  
static <A> L<A> mapOdds(IF1<A> f, L<A> l) {
14  
  ret mapOdds(l, f);
15  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1036369
Snippet name: mapOdds - apply function to elements 1, 3 etc
Eternal ID of this version: #1036369/4
Text MD5: 86191f964737f9cd1754a33a1105e8e6
Transpilation MD5: 0e49342655b51be42c6031dcc540ec25
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-11-28 16:17:07
Source code size: 269 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 168 / 207
Version history: 3 change(s)
Referenced in: [show references]