1 | ln dropeveryother { |
2 | boolean b; |
3 | |
4 | io(L in, L out) { |
5 | if (!in.isEmpty()) |
6 | b = in[0] == out[0]; |
7 | } |
8 | |
9 | i(L in) { |
10 | new L out; |
11 | for (int i = b ? 0 : 1; i < #in; i += 2) |
12 | out.add(in[i]); |
13 | ret out; |
14 | } |
15 | } |
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: | 1206 / 1142 |
Referenced in: | [show references] |