2017-11-25 355 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"]