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#.

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-

Output of bound

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s