[<< wikibooks] F Sharp Programming/Solutions/Lists
== Pair and Unpair ==
Write two functions with the following definitions:

The pair function should convert a list into a list of pairs as follows:

The unpair function should convert a list of pairs back into a traditional list as follows:


=== Solution ===
Using fsi:


== Expand a List ==
Write a function with the following type definition:

The expand function should expand a list as follows:


=== Solution ===
This function can be written easily with or without tail recursion. Here are both functions in fsi:


== Greatest common divisor on lists ==
gcd can be implemented like this using Euler's algorithm:

gcdl can be implemented like this:


== Basic Mergesort ==
split can be implemented like this:

merge can be implemented like this:

msort can be implemented like this: