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

No edit summary
Line 2,598:
 
<pre>g, HHH, 5, YY, ++, ///, \</pre>
 
=={{header|Transd}}==
The task doesn't state explicitly about the order in which substrings should be
displayed. So, here are two variants: one is order-preserving, the other is not
order-preserving.
<syntaxhighlight lang="Scheme">#lang transd
 
MainModule: {
s: "gHHH5YY++///\\",
_start: (λ
(with res ""
(for c in (split s "") do
(if (neq Char(c) (back res)) (+= res ", "))
(+= res c))
(textout res))
 
(lout "Second variant: ")
 
(for v in (values (group-by (split s ""))) do
(textout (if @idx ", ") (join v "")))
)
}</syntaxhighlight>
{{out}}
<pre>
g, HHH, 5, YY, ++, ///, \
Second variant:
++, ///, 5, HHH, YY, \, g
</pre>
 
=={{header|VBA}}==
111

edits