Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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