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

static <A> L<A> mapOdds(L<A> l, IF1<A> f) {
  int n = l(l);
  L<A> out = emptyList(n);
  for i to n: {
    A a = l.get(i);
    if (odd(i))
      a = f.get(a);
    out.add(a);
  }
  ret out;
}

static <A> L<A> mapOdds(IF1<A> f, L<A> l) {
  ret mapOdds(l, f);
}

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: 61 / 98
Version history: 3 change(s)
Referenced in: [show references]