If I have a list
list={3,7,4,5,1}
how to get the List of Intervals /Ranges
result = {{1,3},{3,4},{4,5},{5,7}}
|
If I have a list
how to get the List of Intervals /Ranges
|
|||
|
|
|
Maybe
giving
|
|||
|
|
|
Tom's answer is canonical, but you could also use:
which seems to be marginally faster for large lists. (In which case most of the time is spent sorting.) |
|||||
|