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

16
LINES

< > BotCompany Repo | #1012218 // listToPairs - group elements in pairs; drops last element if single

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

Libraryless. Click here for Pure Java version (4520L/25K).

// possible binary legacy signature
static <A> L<Pair<A>> listToPairs(L<A> l) {
  ret listToPairs((Iterable<A>) l);
}

static <A> L<Pair<A>> listToPairs(Iterable<A> or A[] l) {
  new LPair<A> out;
  Iterator<A> it = iterator(l);
  while ping (it.hasNext()) {
    A a = it.next();
    if (!it.hasNext()) break;
    A b = it.next();
    addPair(out, a, b);
  } 
  ret out;
}

Author comment

Began life as a copy of #1012216

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

No comments. add comment

Snippet ID: #1012218
Snippet name: listToPairs - group elements in pairs; drops last element if single
Eternal ID of this version: #1012218/4
Text MD5: 87ccfde7637fdfc696b72775b8e7237e
Transpilation MD5: e75d8f7c27c7d00977a81a48b82a8730
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-25 01:59:44
Source code size: 387 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 502 / 591
Version history: 3 change(s)
Referenced in: [show references]