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

Comments [hide]

ID Author/Program Comment Date
868 #1000610 Edit suggestion:
!636
!629

main {
static Object androidContext;
static String programID;

public static void main(String[] args) throws Exception {
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;
}
}
}}
2015-08-19 22:48:26  delete 
791 #1000604 (pitcher) 2015-08-18 00:07:22

add comment

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: 825 / 748
Referenced in: [show references]