#require "str";;
let list_of_line line = Str.split (Str.regexp_string " ") line |> List.map int_of_string
Question
I want to write a very simple OCaml program which will take a single line of ints separated by spaces e.g.
1 2 5 8 12 363 9
and store this as a list of ints i.e. [1;2;5;8;12;363;9]. How do I do this in a clean way?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow