RosettaCodeData/Task/Range-extraction/Tailspin/range-extraction.tailspin

19 lines
550 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
templates extract
templates out
when <{start: <=$.end::raw>}> do '$.start;' !
when <{end: <=$.start::raw+1>}> do '$.start;,$.end;' !
otherwise '$.start;-$.end;' !
end out
@: {start: $(1), end: $(1)};
[ $(2..last)... -> #, $@ -> out ] -> '$...;' !
when <=$@.end::raw+1> do @.end: $;
otherwise $@ -> out !
',' !
@: {start: $, end: $};
end 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] -> extract -> !OUT::write