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

10
LINES

< > BotCompany Repo | #1007650 // takeCharsWhile

JavaX fragment (include)

1  
// pred: char -> bool
2  
sS takeCharsWhile(S s, O pred) {
3  
  int i = 0;
4  
  while (i < l(s) && isTrue(callF(pred, s.charAt(i)))) ++i;
5  
  ret substring(s, 0, i);
6  
}
7  
8  
sS lambdaMapLike takeCharsWhile(IPred<Char> f, S s) {
9  
  ret takeCharsWhile(s, f);
10  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1007650
Snippet name: takeCharsWhile
Eternal ID of this version: #1007650/4
Text MD5: 56fcf424c5b290173fde3f67b0aa9bca
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-27 08:38:17
Source code size: 249 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 517 / 541
Version history: 3 change(s)
Referenced in: [show references]