Skip to content

Instantly share code, notes, and snippets.

@sgoguen
Created February 7, 2023 05:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgoguen/893358f063e216cacde14843d6ae663e to your computer and use it in GitHub Desktop.
Save sgoguen/893358f063e216cacde14843d6ae663e to your computer and use it in GitHub Desktop.
Composing Total Recursive Functions
let composeRecursive baseF recursiveFs =
let funcs = [| (fun _ x -> baseF x); yield! recursiveFs |]
let length = bigint(Array.length funcs)
let rec natToObject n =
let r = int(n % length)
let recF = funcs[r]
let f = recF natToObject
f (n / length)
natToObject
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment