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 (88L/1K/3K).

static bool startsWith(S a, S b) {
  ret a != null && a.startsWith(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 13 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lhdilzshxjzv, lnbujpyubztb, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, tslmcundralx, tvejysmllsmz, whxojlpjdney

No comments. add comment

Snippet ID: #1003340
Snippet name: startsWith - now also for lists
Eternal ID of this version: #1003340/7
Text MD5: 1e3d28aa350e7e627c0fd49eb0c1c0a8
Transpilation MD5: 8ab68665a1b2fc7ac520c4739599abf1
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-18 06:08:22
Source code size: 532 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 368 / 1665
Version history: 6 change(s)
Referenced in: [show references]

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