Jump to content

Split a character string based on change of character: Difference between revisions

no 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}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.