Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
7
Task/Bitwise-IO/OCaml/bitwise-io-1.ocaml
Normal file
7
Task/Bitwise-IO/OCaml/bitwise-io-1.ocaml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
let write_7bit_string ~filename ~str =
|
||||
let oc = open_out filename in
|
||||
let ob = IO.output_bits(IO.output_channel oc) in
|
||||
String.iter (fun c -> IO.write_bits ob 7 (int_of_char c)) str;
|
||||
IO.flush_bits ob;
|
||||
close_out oc;
|
||||
;;
|
||||
10
Task/Bitwise-IO/OCaml/bitwise-io-2.ocaml
Normal file
10
Task/Bitwise-IO/OCaml/bitwise-io-2.ocaml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
let read_7bit_string ~filename =
|
||||
let ic = open_in filename in
|
||||
let ib = IO.input_bits(IO.input_channel ic) in
|
||||
let buf = Buffer.create 2048 in
|
||||
try while true do
|
||||
let c = IO.read_bits ib 7 in
|
||||
Buffer.add_char buf (char_of_int c);
|
||||
done; ""
|
||||
with IO.No_more_input ->
|
||||
(Buffer.contents buf)
|
||||
Loading…
Add table
Add a link
Reference in a new issue