Skip to content

Instantly share code, notes, and snippets.

@adilakhter
Created November 21, 2012 10:14
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 adilakhter/4124111 to your computer and use it in GitHub Desktop.
Save adilakhter/4124111 to your computer and use it in GitHub Desktop.
computelength (tail recursive)
// Tail recursive computation of List's length
let length list =
// Auxiliary function to compute length
// It store intermediate result in acc.
let rec lengthAux acc list =
match list with
| [] -> acc
| _::tail -> lengthAux (acc+1) tail
lengthAux 0 list // invoking lengthAux with acc = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment