Created
November 21, 2012 10:14
-
-
Save adilakhter/4124111 to your computer and use it in GitHub Desktop.
computelength (tail recursive)
This file contains 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
// 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