Last active
January 5, 2017 11:38
-
-
Save Octachron/a2c2a97bb432504bde5ebbdf3bbb2ef9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type 'a t = | |
| Leaf of 'a | |
| Node of (int -> 'a) t * (int -> 'a) t | |
let l = Leaf ();; | |
let f n = n | |
let g n k = n + k | |
let n = Node(Leaf f, Leaf f) | |
let n2= Node( Node(Leaf g, Leaf g), Leaf f) | |
let rec apply: 'a. 'a t -> ('a -> int) -> int = | |
fun t k -> match t with | |
| Leaf m -> k m | |
| Node(l, r) -> | |
apply l (fun f -> k (f 0)) + apply r (fun f -> k (f 1) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment