package base

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file random_repr.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

module Array = Array0

module Repr = struct
  type t =
    { st : int array
    ; mutable idx : int
    }

  let of_state : Caml.Random.State.t -> t = Caml.Obj.magic
end

let assign t1 t2 =
  let t1 = Repr.of_state (Lazy.force t1) in
  let t2 = Repr.of_state (Lazy.force t2) in
  Array.blit ~src:t2.st ~src_pos:0 ~dst:t1.st ~dst_pos:0 ~len:(Array.length t1.st);
  t1.idx <- t2.idx

let make_default default = default

let[@inline always] get_state state = state
OCaml

Innovation. Community. Security.