The code snippets listed below defines a function to compute the length of a give list using F#. Note that these functions are also called polymorphic function, as they work with any type of list (as shown in the output).
tail recursive implementation is outlined next.
Following is a more succinct implementation using
> length ;; val it : int = 0 > length [1;2;3;4];; val it : int = 4 > length ['a';'b'];; val it : int = 2