2017-11-25 352 views

回答

4

这是我能想到的通过测试用例的最简单的功能。

let split (str:string) = 
    str.Split ':' 
    |> Seq.collect(fun x -> [":"; x.Trim()]) 
    |> Seq.tail 
    |> Seq.toList 

split "hello world : bye world" // ["hello world"; ":"; "bye world"]