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
Original bug ID: 605 Reporter: administrator Status: closed Resolution: not a bug Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Ken Wakita
Version: 3.02 and 3.03 alpha
OS: Linux and Cygwin
Submission from: n8nat-9.is.titech.ac.jp (131.112.50.139)
Format.bprintf does not accept "%a" format: bprintf_list1
fails to type check. It seems that O'Caml's type checker presumes
that the output for the formatter is an output channel.
Then I removed all the use of "%a" and got fprintf_list2 and
bprintf_list2. Both compiles well but the latter ignores all the
formatting directives.
If there is a work-around please let me know.
Ken Wakita
let fprintf p fmt = Format.fprintf p fmt
let bprintf b fmt = Format.bprintf b fmt
let rec fprintf_list1 p = function
| [] -> ()
| [x] -> fprintf p "%d" x
| (x :: l) -> fprintf p "%d@;%a" x fprintf_list1 l
let rec fprintf_list2 p = function
| [] -> ()
| [x] -> fprintf p "%d" x
| (x :: l) -> fprintf p "%d@;" x; fprintf_list2 p l
(*
let rec bprintf_list1 b = function
| [] -> ()
| [x] -> bprintf b "%d" x
| (x :: l) -> bprintf b "%d@;%a" x bprintf_list1 l
*)
let rec bprintf_list2 b = function
| [] -> ()
| [x] -> bprintf b "%d" x
| (x :: l) -> bprintf b "%d@;" x; bprintf_list2 b l
let rec upto n =
Array.to_list (Array.mapi (fun i _ -> i) (Array.make n ()))
let _ =
let p = Format.std_formatter in
fprintf p " @[%a@]@." fprintf_list1 (upto 100);
fprintf p " @[";
fprintf_list2 p (upto 100);
fprintf p "@]@.";
let b = Buffer.create 1024 in
bprintf b " @[";
bprintf_list2 b (upto 100);
bprintf b "@]@.";
print_string (Buffer.contents b)
The text was updated successfully, but these errors were encountered:
Original bug ID: 605
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Ken Wakita
Version: 3.02 and 3.03 alpha
OS: Linux and Cygwin
Submission from: n8nat-9.is.titech.ac.jp (131.112.50.139)
Format.bprintf does not accept "%a" format: bprintf_list1
fails to type check. It seems that O'Caml's type checker presumes
that the output for the formatter is an output channel.
Then I removed all the use of "%a" and got fprintf_list2 and
bprintf_list2. Both compiles well but the latter ignores all the
formatting directives.
If there is a work-around please let me know.
Ken Wakita
let fprintf p fmt = Format.fprintf p fmt
let bprintf b fmt = Format.bprintf b fmt
let rec fprintf_list1 p = function
| [] -> ()
| [x] -> fprintf p "%d" x
| (x :: l) -> fprintf p "%d@;%a" x fprintf_list1 l
let rec fprintf_list2 p = function
| [] -> ()
| [x] -> fprintf p "%d" x
| (x :: l) -> fprintf p "%d@;" x; fprintf_list2 p l
(*
let rec bprintf_list1 b = function
| [] -> ()
| [x] -> bprintf b "%d" x
| (x :: l) -> bprintf b "%d@;%a" x bprintf_list1 l
*)
let rec bprintf_list2 b = function
| [] -> ()
| [x] -> bprintf b "%d" x
| (x :: l) -> bprintf b "%d@;" x; bprintf_list2 b l
let rec upto n =
Array.to_list (Array.mapi (fun i _ -> i) (Array.make n ()))
let _ =
let p = Format.std_formatter in
fprintf p " @[%a@]@." fprintf_list1 (upto 100);
fprintf p " @[";
fprintf_list2 p (upto 100);
fprintf p "@]@.";
let b = Buffer.create 1024 in
bprintf b " @[";
bprintf_list2 b (upto 100);
bprintf b "@]@.";
print_string (Buffer.contents b)
The text was updated successfully, but these errors were encountered: