Skip to content

Instantly share code, notes, and snippets.

View chambart's full-sized avatar

Pierre Chambart chambart

  • OCamlPro & Nomadic
  • Paris, France
View GitHub Profile
#!/usr/bin/env ocaml
(* run "./EzSudoku n" to generate template .ml file to fill with your n^2*n^2 sudoku problem
You probably shouldn't put anything bigger than 3. Or 2 in fact... *)
let size =
try int_of_string Sys.argv.(1) with
| _ -> 2
@chambart
chambart / packed_fields_gadt.ml
Last active April 3, 2023 02:00
Packed fields in integers
type zero = unit
type 'a succ = unit -> 'a
type one = zero succ
type 'a plus_1 = 'a succ
type 'a plus_2 = 'a plus_1 plus_1
type 'a plus_4 = 'a plus_2 plus_2
type 'a plus_8 = 'a plus_4 plus_4
@chambart
chambart / gist:a3b05c0895f6afb9cf01
Created July 3, 2015 15:22
Peano numbers with ocaml functors
type zero = unit
type 'a succ = unit -> 'a
type 'a nat =
| Zero : zero nat
| Succ : 'a nat -> 'a succ nat
module type T = sig
type t
val v : t nat