3

I'm trying to take a string like "hello world : bye world" and get ["hello world"; ":" ;"bye world"].

0

1 Answer 1

4

This is the simplest function I can think of to pass your test case.

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"]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.