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 17:16, 29 December 2023
, 4 months ago→K: add
(→BQN: also handle repeating blocks) |
(→K: add) |
||
Line 1,710:
<pre>string: gHHH5YY++///\
separated: g, HHH, 5, YY, ++, ///, \</pre>
=={{header|K}}==
","/ split "gHHH5YY++///\\"</syntaxhighlight>
{{out}}
<pre>"g,HHH,5,YY,++,///,\\"</pre>
=={{header|Kotlin}}==
<syntaxhighlight lang="kotlin">// version 1.0.6
▲<syntaxhighlight lang="scala">// version 1.0.6
fun splitOnChange(s: String): String {
Line 1,728 ⟶ 1,734:
println(splitOnChange(s))
}</syntaxhighlight>
{{out}}
<pre>
Line 1,735 ⟶ 1,740:
=== Using fold() ===
<syntaxhighlight lang="kotlin">
Line 1,747 ⟶ 1,751:
}
</syntaxhighlight>
{{out}}
<pre>
|