18 lines
629 B
Plaintext
18 lines
629 B
Plaintext
(define make-range
|
|
Start Start -> ["," Start]
|
|
Start End -> ["," Start "," End] where (= End (+ Start 1))
|
|
Start End -> ["," Start "-" End])
|
|
|
|
(define range-extract-0
|
|
Start End [] -> (make-range Start End)
|
|
Start End [A|As] -> (range-extract-0 Start A As) where (= (+ 1 End) A)
|
|
Start End [A|As] -> (append (make-range Start End) (range-extract-0 A A As)))
|
|
|
|
(define range-extract
|
|
[A |As] -> (FORMAT NIL "~{~a~}" (tail (range-extract-0 A A As))))
|
|
|
|
(range-extract [ 0 1 2 4 6 7 8 11 12 14
|
|
15 16 17 18 19 20 21 22 23 24
|
|
25 27 28 29 30 31 32 33 35 36
|
|
37 38 39])
|