You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Seems like extlib should include IO.scanf for symmetry with IO.printf:
--- IO.mli.orig 2008-07-13 14:36:59.000000000 -0700
+++ IO.mli 2008-07-13 14:02:02.000000000 -0700
@@ -135,6 +135,9 @@
(** {6 Utilities} *)
+val scanf : input -> ('a, 'b, 'c, 'd) Scanf.scanner
+(** The scanf function works for any input. *)
+
val printf : 'a output -> ('b, unit, string, unit) format4 -> 'b
(** The printf function works for any output. *)
--- IO.ml.orig 2008-07-13 14:36:59.000000000 -0700
+++ IO.ml 2008-07-13 14:06:12.000000000 -0700
@@ -145,6 +145,10 @@
if p + l > sl || p < 0 || l < 0 then invalid_arg "IO.output";
o.out_output s p l
+let scanf i fmt =
+ let ib = Scanf.Scanning.from_function (fun () -> read i) in
+ Scanf.kscanf ib (fun _ exn -> raise exn) fmt
+
let printf o fmt =
Printf.kprintf (fun s -> nwrite o s) fmt
Reported by warrenharris1 on 2008-07-13 21:38:27
The text was updated successfully, but these errors were encountered:
Note that it needs special handling for IO.No_more_input.
Consider :
let io = IO.input_string "hello world";;
IO.scanf io "%s %s" (fun x y -> print_endline x; print_endline y);;
Originally reported on Google Code with ID 8
Reported by
warrenharris1
on 2008-07-13 21:38:27The text was updated successfully, but these errors were encountered: