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

23
LINES

< > BotCompany Repo | #1003340 // startsWith - now also for lists

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

Transpiled version (2491L) is out of date.

static bool startsWith(S a, S b) {
  ret a != null && a.startsWith(unnull(b));
}

static bool startsWith(S a, char c) {
  ret nemptyString(a) && a.charAt(0) == c;
}

ifclass Matches
  static bool startsWith(S a, S b, Matches m) {
    if (!startsWith(a, b)) false;
    if (m != null) m.m = new S[] {substring(a, strL(b))};
    true;
  }
endif

static bool startsWith(L a, L b) {
  if (a == null || listL(b) > listL(a)) ret false;
  for (int i = 0; i < listL(b); i++)
    if (neq(a.get(i), b.get(i)))
      ret false;
  ret true;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1003340
Snippet name: startsWith - now also for lists
Eternal ID of this version: #1003340/9
Text MD5: f9601e365ddb25e386906b83726d9bc1
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-09-02 18:18:30
Source code size: 555 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 768 / 2202
Version history: 8 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1029777 - startsWith_addingSlash - TODO: optimize
#1030163 - startsWith_possiblyCI
#1030949 - Transpiler output of #1031393