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 19:14, 14 August 2017
, 6 years agoAdded 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}}==
|