package combinat

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

Internal iterators for combinatorial objects.

type +'a iter = ('a -> unit) -> unit
val partitions : n:int -> k:int -> int array iter

Iterator over the partitions of an integer n into k parts.

val partitions_with_zeros : n:int -> k:int -> int array iter

Iterator over the partitions of an integer n into k parts, including partitions where some elements are zero.

val permutations : 'a list -> 'a array iter

Iterator over the permutations of a set of n elements.

permutations ~n:3 = [0;1;2]; [0;2;1]; [1;0;2]; [1;2;0]; [2;0;1]; [2;1;0]

val sequences : 'a list -> k:int -> 'a array iter

Iterator over the sequences of length k of a list of elements. Sequences are a superset of combinations that also consider every ordering.

val sequences_restricted : 'a list list -> 'a array iter

Iterator over all sequences where the ith element of the sequence comes from the ith list.

val combinations : 'a list -> k:int -> 'a array iter

Iterator over the combinations of size k a set of n elements.

combinations ~n:4 ~k:2 = [0;1]; [0;2]; [0;3]; [1;2]; [1;3]; [2;3]

val compositions : n:int -> k:int -> int array iter

Iterator over the k compositions of an integer n.

OCaml

Innovation. Community. Security.