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

Added F#
(→‎{{header|jq}}: def runs:)
(Added F#)
Line 360:
output string: g, HHH, 5, YY, ++, ///, \
</pre>
 
=={{header|F_Sharp|F#}}==
<lang fsharp>open System.Text.RegularExpressions
let splitRuns s = Regex("""(.)\1*""").Matches(s) |> Seq.cast<Match> |> Seq.map (fun m -> m.Value) |> Seq.toList
printfn "%A" (splitRuns """gHHH5YY++///\""")</lang>
{{out}}
<pre>["g"; "HHH"; "5"; "YY"; "++"; "///"; "\"]</pre>
 
=={{header|Forth}}==
Anonymous user