Anonymous user
Split a character string based on change of character: Difference between revisions
Split a character string based on change of character (view source)
Revision as of 18:12, 29 June 2018
, 6 years agono edit summary
m (→{{header|Go}}: User new and more efficient strings.Builder) |
No edit summary |
||
Line 835:
return s
end</lang>
=={{header|Maple}}==
Added an additional backlash to escape the \ character at the end.
<lang Maple>splitChange := proc(str::string)
local start,i,len;
start := 1;
len := StringTools:-Length(str);
for i from 2 to len do
if str[i] <> str[start] then
printf("%s, ", str[start..i-1]);
start := i:
end if;
end do;
printf("%s", str[start..len]);
end proc;
splitChange("gHHH5YY++///\\");</lang>
{{out}}
<pre>g, HHH, 5, YY, ++, ///, \</pre>
=={{header|Mathematica}}==
|