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

8
LINES

< > BotCompany Repo | #1032324 // replace_optimized - replace only when a and b are different

JavaX fragment (include)

// replace all occurrences of a in s with b
sS replace_optimized(S s, S a, S b) {
  ret eq(a, b) ? s : replace(s, a, b);
}

sS replace_optimized(S s, char a, char b) {
  ret a == b ? s : replace(s, a, b);
}

Author comment

Began life as a copy of #1007775

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1032324
Snippet name: replace_optimized - replace only when a and b are different
Eternal ID of this version: #1032324/2
Text MD5: e124759effa9201f00f2f050e32035b1
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-27 07:37:29
Source code size: 213 bytes / 8 lines
Pitched / IR pitched: No / No
Views / Downloads: 135 / 155
Version history: 1 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)