Skip to content

Instantly share code, notes, and snippets.

@gsg
Created September 15, 2016 19:23
Show Gist options
  • Save gsg/83a224b338ef07c552d17fe8f620557c to your computer and use it in GitHub Desktop.
Save gsg/83a224b338ef07c552d17fe8f620557c to your computer and use it in GitHub Desktop.
module LazyFix = struct
let rec fix f = f (lazy (fix f))
let f_open = fun clo (x : int) ->
if x <= 0 then x else (snd (Lazy.force clo)) (x - 1)
let g_open = fun clo (x : int) ->
if x <= 0 then x else (fst (Lazy.force clo)) (x - 1)
let clo = fix (fun clo -> f_open clo, g_open clo)
let f = fst clo
let g = snd clo
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment