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

14
LINES

< > BotCompany Repo | #1002116 // liftLast - pop & return last element(s) off a list

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

Libraryless. Click here for Pure Java version (2179L/14K).

1  
static <A> A liftLast(L<A> l) {
2  
  if (empty(l)) null;
3  
  int i = l(l)-1;
4  
  A a = l.get(i);
5  
  l.remove(i);
6  
  ret a;
7  
}
8  
9  
static <A> L<A> liftLast(int n, L<A> l) {
10  
  int i = l(l)-n;
11  
  L<A> part = cloneSubList(l, i);
12  
  removeSubList(l, i);
13  
  ret part;
14  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 18 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, wnsclhtenguj, xrpafgyirdlv

No comments. add comment

Snippet ID: #1002116
Snippet name: liftLast - pop & return last element(s) off a list
Eternal ID of this version: #1002116/4
Text MD5: a02ab97e4ce755373d3504fdd2f04029
Transpilation MD5: 782caadbcde38fda21053ec0826e2e1d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-09-25 18:33:50
Source code size: 260 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 644 / 3077
Version history: 3 change(s)
Referenced in: [show references]