Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
7
Task/Read-entire-file/OCaml/read-entire-file-1.ocaml
Normal file
7
Task/Read-entire-file/OCaml/read-entire-file-1.ocaml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
let load_file f =
|
||||
let ic = open_in f in
|
||||
let n = in_channel_length ic in
|
||||
let s = Bytes.create n in
|
||||
really_input ic s 0 n;
|
||||
close_in ic;
|
||||
(s)
|
||||
1
Task/Read-entire-file/OCaml/read-entire-file-2.ocaml
Normal file
1
Task/Read-entire-file/OCaml/read-entire-file-2.ocaml
Normal file
|
|
@ -0,0 +1 @@
|
|||
(Bytes.unsafe_to_string s)
|
||||
2
Task/Read-entire-file/OCaml/read-entire-file-3.ocaml
Normal file
2
Task/Read-entire-file/OCaml/read-entire-file-3.ocaml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
type big_string =
|
||||
(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t
|
||||
9
Task/Read-entire-file/OCaml/read-entire-file-4.ocaml
Normal file
9
Task/Read-entire-file/OCaml/read-entire-file-4.ocaml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
let load_big_file filename =
|
||||
let fd = Unix.openfile filename [Unix.O_RDONLY] 0o640 in
|
||||
let len = Unix.lseek fd 0 Unix.SEEK_END in
|
||||
let _ = Unix.lseek fd 0 Unix.SEEK_SET in
|
||||
let shared = false in (* modifications are done in memory only *)
|
||||
let bstr = Bigarray.Array1.map_file fd
|
||||
Bigarray.char Bigarray.c_layout shared len in
|
||||
Unix.close fd;
|
||||
(bstr)
|
||||
7
Task/Read-entire-file/OCaml/read-entire-file-5.ocaml
Normal file
7
Task/Read-entire-file/OCaml/read-entire-file-5.ocaml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
let () =
|
||||
let bstr = load_big_file Sys.argv.(1) in
|
||||
let len = Bigarray.Array1.dim bstr in
|
||||
for i = 0 to pred len do
|
||||
let c = bstr.{i} in
|
||||
print_char c
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue