xkcd936.ml 368 B

12345678910111213
  1. open Bigarray
  2. open Lib
  3. let () =
  4. Random.self_init ();
  5. let fd = Unix.openfile "words.txt" [ Unix.O_RDONLY ] 0 in
  6. let mf = Unix.map_file fd char c_layout false [| -1 |] in
  7. let arr = array1_of_genarray mf in
  8. let len = Array1.dim arr in
  9. (fun _ -> len |> Random.int |> Lines.line arr len)
  10. |> List.init 4 |> String.concat "-" |> print_endline;
  11. Unix.close fd