Computing bound of a List with F#
Following code snippet shows how to compute bound (i.e the min and max elements) of a List using F#.
[gist]4511020[/gist]
Solution outlined here is quite trivial and use the pattern matching facilities of F#. In case of an empty list (line 3), it returns None; otherwise, it returns the bound as Some (int*int) (line 8).
Therefore, the signature of bound is given by-
[gist]4511458[/gist]
Output of bound -
[gist]4511478[/gist]
Comments ()