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]

Libraryless. Click here for Pure Java version (2491L/16K).

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;
    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   

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

No comments. add comment

Snippet ID: #1003340
Snippet name: startsWith - now also for lists
Eternal ID of this version: #1003340/8
Text MD5: 893d908eb531075922b3012bce1bf7de
Transpilation MD5: 8842880e3968ece4e041ad5be5a790ae
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-20 00:41:53
Source code size: 540 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 412 / 1723
Version history: 7 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1003340 & http://1003340.tinybrain.de