RosettaCodeData/Task/Binary-strings/Icon/binary-strings-2.icon

17 lines
303 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
procedure replace(s1, s2, s3) #: string replacement
local result, i
result := ""
i := *s2
if i = 0 then fail # would loop on empty string
s1 ? {
while result ||:= tab(find(s2)) do {
result ||:= s3
move(i)
}
return result || tab(0)
}
end