package base

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

Source file array_permute.ml

1
2
3
4
5
6
7
8
9
10
11
12
(** An internal-only module factored out due to a circular dependency between core_array
    and core_list.  Contains code for permuting an array. *)

open! Import
include Array0

(** randomly permute an array. *)
let permute ?(random_state = Random.State.default) t =
  for i = length t downto 2 do
    swap t (i - 1) (Random.State.int random_state i)
  done
;;
OCaml

Innovation. Community. Security.