Reputation: 303
I have a list as let a = ["q0,x";"q1,y"];
which is of type string list
.
I want to make it as [("q0","x");("q1","y")];
which is a list of (string * string)
tuples.
How do I do that??
Upvotes: 0
Views: 555
Reputation: 2540
You can use module Str and the function split
:
let split =
List.map (fun str ->
match Str.split (Str.regexp ",") str with
| a :: b :: _ -> a, b
| _ -> assert false (* should not happen *))
Upvotes: 3