Skip to content

Instantly share code, notes, and snippets.

@fetburner
Created May 18, 2020 16:58
Show Gist options
  • Save fetburner/616516d41bdc6e0c1de557d1c54cb527 to your computer and use it in GitHub Desktop.
Save fetburner/616516d41bdc6e0c1de557d1c54cb527 to your computer and use it in GitHub Desktop.
(* チャーチ数 *)
type church_nat = { nat_fold : 'a. ('a -> 'a) -> 'a -> 'a }
(* チャーチエンコーディングした二進数 *)
type church_bin = { bin_fold : 'a. f0:('a -> 'a) -> f1:('a -> 'a) -> 'a -> 'a }
(* チャーチ数nを受け取って,
n.nat_fold succ 1
= m.bin_fold ~f0:(fun x -> 2 * x) ~f1:(fun x -> 2 * x + 1) 1
が成り立つような二進数mを返す関数church_bin_of_church_natを記述せよ. *)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment