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

10
LINES

< > BotCompany Repo | #1015295 // smartLastIndexOf - returns l(s) if not found

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

Transpiled version (2580L) is out of date.

static int smartLastIndexOf(S s, char c) {
  if (s == null) ret 0;
  int i = s.lastIndexOf(c);
  ret i >= 0 ? i : l(s);
}

static <A> int smartLastIndexOf(L<A> l, A sub) {
  int i = lastIndexOf(l, sub);
  ret i < 0 ? l(l) : i;
}

Author comment

Began life as a copy of #1002497

download  show line numbers  debug dex  old transpilations   

Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, ofpaelxlmzfo, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney

No comments. add comment

Snippet ID: #1015295
Snippet name: smartLastIndexOf - returns l(s) if not found
Eternal ID of this version: #1015295/5
Text MD5: b7dddfcd91c4681ce61d88b6d4b3461f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-10-31 12:33:04
Source code size: 237 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 270 / 722
Version history: 4 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)