Skip to content

Instantly share code, notes, and snippets.

@hellojukay
Created June 27, 2021 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hellojukay/595f6b14dfb11cd45bb57d9c11ba7143 to your computer and use it in GitHub Desktop.
Save hellojukay/595f6b14dfb11cd45bb57d9c11ba7143 to your computer and use it in GitHub Desktop.
progress bar write in Ocaml
;;
#load "unix.cma"
let rec repeat str n =
match n with 0 -> str | 1 -> str | n -> str ^ repeat str (n - 1)
let () =
let sum = ref 1 in
while true do
Printf.printf "[%d%%]%s" !sum (repeat "#" !sum);
flush stdout;
Unix.sleepf 0.03;
Printf.printf "%s" "\r";
Printf.printf "%s" (repeat " " 110);
Printf.printf "%s" "\r";
flush stdout;
if !sum == 100 then sum := 0;
sum := !sum + 1
done
@hellojukay
Copy link
Author

image

@hellojukay
Copy link
Author

Monaco font best

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment