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

10
LINES

< > BotCompany Repo | #1007650 // takeCharsWhile

JavaX fragment (include)

// pred: char -> bool
sS takeCharsWhile(S s, O pred) {
  int i = 0;
  while (i < l(s) && isTrue(callF(pred, s.charAt(i)))) ++i;
  ret substring(s, 0, i);
}

sS lambdaMapLike takeCharsWhile(IPred<Char> f, S s) {
  ret takeCharsWhile(s, f);
}

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: 439 / 455
Version history: 3 change(s)
Referenced in: [show references]