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.

1  
static bool startsWith(S a, S b) {
2  
  ret a != null && a.startsWith(unnull(b));
3  
}
4  
5  
static bool startsWith(S a, char c) {
6  
  ret nemptyString(a) && a.charAt(0) == c;
7  
}
8  
9  
ifclass Matches
10  
  static bool startsWith(S a, S b, Matches m) {
11  
    if (!startsWith(a, b)) false;
12  
    if (m != null) m.m = new S[] {substring(a, strL(b))};
13  
    true;
14  
  }
15  
endif
16  
17  
static bool startsWith(L a, L b) {
18  
  if (a == null || listL(b) > listL(a)) ret false;
19  
  for (int i = 0; i < listL(b); i++)
20  
    if (neq(a.get(i), b.get(i)))
21  
      ret false;
22  
  ret true;
23  
}

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: 523 / 1872
Version history: 8 change(s)
Referenced in: [show references]