For example suppose I have a sorted list
val sorted = List(1, 5, 15, 37, 39, 42, 50)
The smallest gap is (39-37)=2. How would I obtain this result? I have been looking at foldLeft I get the feeling it is similar to what I need but not quite the right thing
[Edit]
You can use a fold as well: