Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
12
Task/Range-extraction/Maple/range-extraction.maple
Normal file
12
Task/Range-extraction/Maple/range-extraction.maple
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
lst := [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]:
|
||||
r1,r2:= lst[1],lst[1]:
|
||||
for i from 2 to numelems(lst) do
|
||||
if lst[i] - lst[i-1] = 1 then #consecutive
|
||||
r2 := lst[i]:
|
||||
else #break
|
||||
printf(piecewise(r2-r1=1, "%d,%d,", r2-r1>1,"%d-%d,", "%d,"), r1, r2):
|
||||
r1,r2:= lst[i],lst[i]:
|
||||
fi:
|
||||
od:
|
||||
printf(piecewise(r2-r1=1, "%d,%d", r2-r1>1,"%d-%d", "%d"), r1, r2):
|
||||
Loading…
Add table
Add a link
Reference in a new issue