mergeRanges

This function returns a contiguous range if ranges can be merged, if not returns null. Note that this is not commutative. The outer and inner ranges differ, and multiplier values matter too.

For an inner range: (a..b).mergeRanges(c..d) where (c..d) is not a single value, it is required that ca..cb is consecutive with (c+1)*a..(c+1)b. That is the case if (cb)+1>=(c+1)*a.