Reputation: 65
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?
Upvotes: 0
Views: 192
Reputation: 25812
#require "str";;
let list_of_line line = Str.split (Str.regexp_string " ") line |> List.map int_of_string
Upvotes: 1