27 lines
550 B
Text
27 lines
550 B
Text
|
|
#require "fmt"
|
||
|
|
(* #directory "_build/src" *)
|
||
|
|
(* #load "psq.cma" *)
|
||
|
|
|
||
|
|
let shuff arr =
|
||
|
|
let n = Array.length arr in
|
||
|
|
for i = 0 to n - 2 do
|
||
|
|
let j = Random.int (n - i) + i in
|
||
|
|
let t = arr.(i) in
|
||
|
|
arr.(i) <- arr.(j);
|
||
|
|
arr.(j) <- t
|
||
|
|
done
|
||
|
|
|
||
|
|
let permutation n =
|
||
|
|
let arr = Array.init n (fun x -> x) in
|
||
|
|
shuff arr;
|
||
|
|
Array.to_list arr
|
||
|
|
|
||
|
|
let rec (--) a b = if a > b then [] else a :: succ a -- b
|
||
|
|
|
||
|
|
module I = struct type t = int let compare = compare end
|
||
|
|
module Q = Psq.Make (I) (I)
|
||
|
|
|
||
|
|
let pp_q = Q.pp_dump Fmt.int Fmt.int
|
||
|
|
;;
|
||
|
|
#install_printer pp_q
|