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

15
LINES

< > BotCompany Repo | #1000489 // Drop every other (learner)

JavaX fragment (include)

ln dropeveryother {
  boolean b;

  io(L in, L out) {
    if (!in.isEmpty())
      b = in[0] == out[0];
  }

  i(L in) {
    new L out;
    for (int i = b ? 0 : 1; i < #in; i += 2)
      out.add(in[i]);
    ret out;
  }
}

Author comment

Typed on the tablet - that's why it's so short!

But why not always program this way? We just need an expander (translator).

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

2 comment(s) hidden. show

Snippet ID: #1000489
Snippet name: Drop every other (learner)
Eternal ID of this version: #1000489/1
Text MD5: 58143651f8040a1adcec87dc0df28caf
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-08-09 16:25:15
Source code size: 235 bytes / 15 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 929 / 855
Referenced in: [show references]