Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. (**
  2. compiled with
  3. ocamlopt ascii.ml -o ascii
  4. or
  5. ocamlopt.opt.exe ./ascii.ml -o ./ascii.exe
  6. *)
  7.  
  8. let () =
  9. Printf.printf "oct | dec | hex | char%10soct | dec | hex | char\n" " "
  10.  
  11. let () =
  12. let to_char_string = function
  13. 127 -> "DEL"
  14. | i -> i |> char_of_int |> Char.escaped
  15. in
  16. for i = 32 to 80 do
  17. let p = Printf.printf "%3o %3d %3X %4s\t\t%3o %3d %3X %4s\n" i i i (char_of_int i |> Char.escaped) in
  18. let i = i + 47 in
  19. p i i i (i |> to_char_string)
  20. done
  21.  
  22. let () = flush stdout
  23.  
  24. let _ = input_char stdin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement