Libraryless. Click here for Pure Java version (3805L/22K).
sS lambdaMapLike filterChars(IPred<Char> pred, S s) { replace test with pred.get . if (empty(s)) null; int n = l(s), i = 0; char c = s.charAt(i); bool totality = test(c); for (++i; i < n; i++) { c = s.charAt(i); bool b = test(c); if (b != totality) { // diverse case new StringBuilder buf; if (totality) buf.append(substring(s, 0, i)); while ping (true) { if (b) buf.append(c); if (++i >= n) break; c = s.charAt(i); b = test(c); } ret buf.toString(); } } ret totality ? s : ""; }
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1021348 |
Snippet name: | filterChars |
Eternal ID of this version: | #1021348/9 |
Text MD5: | aebaf7d53d9d53856cf59019be689704 |
Transpilation MD5: | 881a3d943f0e2f944767c9d1a2a1279d |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-16 07:32:26 |
Source code size: | 618 bytes / 27 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 327 / 461 |
Version history: | 8 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1034537 - ICharPred - predicate on char |