package iter

  1. Overview
  2. Docs
Simple abstraction over `iter` functions, intended to iterate efficiently on collections while performing some transformations

Install

Dune Dependency

Authors

Maintainers

Sources

iter-1.8.tbz
sha256=f8739ca05ae9c4ba8aa20c0d4197e74409f2b659a17f12730d42af1fd9f43023
sha512=975c9759d12f39779bd258d2a11957acf16f16008b17abf40b48853f612eaa558665f212aae6137c4231ed28945b2a081836d79ec7efe40dcd527f13d25c2269

doc/src/iter.bigarray/IterBigarray.ml.html

Source file IterBigarray.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
(* This file is free software, part of iter. See file "license" for more details. *)

(** {1 Interface and Helpers for bigarrays} *)

let bigarray_map_file fd ty lay b len =
  Unix.map_file fd ty lay b [| len |] |> Bigarray.array1_of_genarray

let of_bigarray b yield =
  let len = Bigarray.Array1.dim b in
  for i = 0 to len - 1 do
    yield b.{i}
  done

let mmap filename yield =
  let fd = Unix.openfile filename [ Unix.O_RDONLY ] 0 in
  let len = Unix.lseek fd 0 Unix.SEEK_END in
  let _ = Unix.lseek fd 0 Unix.SEEK_SET in
  let b = bigarray_map_file fd Bigarray.char Bigarray.c_layout false len in
  try
    of_bigarray b yield;
    Unix.close fd
  with e ->
    Unix.close fd;
    raise e
  [@@ocaml.warning "-3"]
OCaml

Innovation. Community. Security.