Dear ALL,
I have a sorted sequence of integers as follows:
1, 2, 3, 4, 5, 7, 9, 10, 11, 13, 15
I want to convert this sequence to a string, with adjacent numbers "compressed" to include only the first and last in the interval between them. So, for the above case I would have a string in the following format:
'1-5 7 9-11 13 15'
Could someone out there give some hints on how to write a function to achieve this? A simple working example (as it is possible that this problem has already been addressed) would be most helpful.
Many thanks in advance!
With warmest regards,