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).

static <A> A liftLast(L<A> l) {
  if (empty(l)) null;
  int i = l(l)-1;
  A a = l.get(i);
  l.remove(i);
  ret a;
}

static <A> L<A> liftLast(int n, L<A> l) {
  int i = l(l)-n;
  L<A> part = cloneSubList(l, i);
  removeSubList(l, i);
  ret part;
}

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: 737 / 3200
Version history: 3 change(s)
Referenced in: #1002427 - Accellerating 629 (SPIKE)
#1002780 - popLast - synonym of liftLast
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)