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

15
LINES

< > BotCompany Repo | #1003099 // takeLast function (take last n elements of a list or characters of a string)

JavaX fragment (include)

static <A> L<A> takeLast(L<A> l, int n) {
  return newSubList(l, l(l)-n);
}

static <A> L<A> takeLast(int n, L<A> l) {
  ret takeLast(l, n);
}

static S takeLast(int n, S s) {
  ret substring(s, l(s)-n);
}

static S takeLast(S s, int n) {
  ret substring(s, l(s)-n);
}

Author comment

Began life as a copy of #1000798

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xrpafgyirdlv

No comments. add comment

Snippet ID: #1003099
Snippet name: takeLast function (take last n elements of a list or characters of a string)
Eternal ID of this version: #1003099/5
Text MD5: 2fdb9f5f39282a37d6052890b67bb727
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-18 00:32:00
Source code size: 284 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 665 / 725
Version history: 4 change(s)
Referenced in: [show references]