From years of experience, I have found that scanf is unlikely to do exactly what you want. This is normal for a quick test program.
One possibility is to use Str.split
:
let floats_of_string s = List.map float_of_string (Str.split (Str.regexp "[, \t]+") s)
You may need to make regexp a little tougher if you want to detect invalid input.
source share