NextGReadHelpers to read simple space-based files like the ones used in the Google Hash Code competition.
val int : int castval bit : bool castval float : float castval char : char castval string : string castval no_space_string : string castCast that checks that its input does not contain a space and returns it right away. In seq, list and array below, it is no different to string. In the tupleng functions below, it is only different to string in last position.
For each tuple size n (up to 5), we provide a function tuple<n> taking n cast functions and returning a tuple.
tuple2 ~sep cast1 cast2 is a cast that cuts its input at the first sep (which defaults to blank characters) and applies cast1 on the first part and cast2 on the second part, returning the 2-tuple (pair) of the results.
tuple3 ~sep cast1 cast2 cast3 is a cast that cuts its input at the two first seps (which default to blank characters) and applies cast1 on the first part, cast2 on the second part and cast3 on the third part, returning the 3-tuple of the results.
Alias for tuple3.
val tuple4 :
?sep:Str.regexp ->
'a cast ->
'b cast ->
'c cast ->
'd cast ->
('a * 'b * 'c * 'd) casttuple4 ~sep cast1 cast2 cast3 cast4 is a cast that cuts its input at the three first seps (which default to blank characters) and applies cast1 on the first part, cast2 on the second part, cast3 on the third part and cast4 on the fourth part, returning the 4-tuple of the results.
val tuple5 :
?sep:Str.regexp ->
'a cast ->
'b cast ->
'c cast ->
'd cast ->
'e cast ->
('a * 'b * 'c * 'd * 'e) casttuple5 ~sep cast1 cast2 cast3 cast4 cast5 is a cast that cuts its input at the first four seps (which default to blank characters) and applies cast1 on the first part, cast2 on the second part, cast3 on the third part, cast4 on the fourth part and cast5 on the fifth part, returning the 5-tuple of the results.
val tuple6 :
?sep:Str.regexp ->
'a cast ->
'b cast ->
'c cast ->
'd cast ->
'e cast ->
'f cast ->
('a * 'b * 'c * 'd * 'e * 'f) casttuple6 ~sep cast1 cast2 cast3 cast4 cast5 cast6 is a cast that cuts its input at the first five seps (which default to blank characters) and applies cast1 on the first part, cast2 on the second part, cast3 on the third part, cast4 on the fourth part, cast5 on the fifth part and cast6 on the sixth part, returning the 6-tuple of the results.
val cast : (string -> 'a) -> 'a castCreate a cast from a string -> 'a function.
val of_string : 'a cast -> string -> 'astring c s reads s and casts it using c.
val line : 'a cast -> 'aline c reads one line from standard input and casts it using c.
val line_of_chan : Stdlib.in_channel -> 'a cast -> 'aline_from_chan ichan c reads one line from ichan and casts it using c.
val lines_until_empty : 'a cast -> 'a listlines_until_empty c reads lines from standard input and casts them using c. It stops at the first empty line it meets.
val lines_of_chan_until_empty : Stdlib.in_channel -> 'a cast -> 'a listlines_of_chan_until_empty ichan c reads lines from ichan and casts them using c. It stops at the first empty line it meets.