Range modifications: Difference between revisions

Content added Content deleted
m (→‎{{header|Phix}}: added high range)
Line 430: Line 430:
remove 9
remove 9
remove 7
remove 7
Start with "13-14,22-22,100000999999-100001000000"
Start with "13-14,22-22,100000999999-100001000000,100001000003-999999999999"
remove 22
remove 22
remove 100000999999
remove 100000999999
remove 100001000000
remove 100001000000
add 100001000001
add 100001000001
add 100001000002
remove 100001000002
remove 100001000001
remove 100001000001
""","\n",no_empty:=true)
""","\n",no_empty:=true)
Line 443: Line 445:
string ti = tests[i]
string ti = tests[i]
if match("Start with",ti) then
if match("Start with",ti) then
{{range}} = scanf(ti,"Start with \"%s\"")
{{range}} = scanf(trim(ti),"Start with \"%s\"")
ranges = split(range,",")
ranges = split(range,",")
ranges = vslice(apply(true,scanf,{ranges,{"%d-%d"}}),1)
ranges = vslice(apply(true,scanf,{ranges,{"%d-%d"}}),1)
printf(1,"\n Start range: \"%s\"\n",{range})
printf(1,"\n Start with: \"%s\"\n",{range})
-- ^^ ^^
-- ^^ ^^
else
else
Line 460: Line 462:
<small>(Note that all double-quotes in the output were deliberately added in the last two printf() statements, mainly to prove there are no unnecessary spaces, etc, and are (see ^^) obviously trivial to remove.)</small>
<small>(Note that all double-quotes in the output were deliberately added in the last two printf() statements, mainly to prove there are no unnecessary spaces, etc, and are (see ^^) obviously trivial to remove.)</small>
<pre>
<pre>
Start range: ""
Start with: ""
add 77 -> "77-77"
add 77 -> "77-77"
add 79 -> "77-77,79-79"
add 79 -> "77-77,79-79"
Line 468: Line 470:
remove 79 -> ""
remove 79 -> ""


Start range: "1-3,5-5"
Start with: "1-3,5-5"
add 1 -> "1-3,5-5"
add 1 -> "1-3,5-5"
remove 4 -> "1-3,5-5"
remove 4 -> "1-3,5-5"
Line 476: Line 478:
remove 7 -> "1-3,5-6,8-8"
remove 7 -> "1-3,5-6,8-8"


Start range: "1-5,10-25,27-30"
Start with: "1-5,10-25,27-30"
add 26 -> "1-5,10-30"
add 26 -> "1-5,10-30"
add 9 -> "1-5,9-30"
add 9 -> "1-5,9-30"
Line 484: Line 486:
remove 7 -> "1-5,10-25,27-30"
remove 7 -> "1-5,10-25,27-30"


Start range: "13-14,22-22,100000999999-100001000000"
Start with: "13-14,22-22,100000999999-100001000000,100001000003-999999999999"
remove 22 -> "13-14,100000999999-100001000000"
remove 22 -> "13-14,100000999999-100001000000,100001000003-999999999999"
remove 100000999999 -> "13-14,100001000000-100001000000"
remove 100000999999 -> "13-14,100001000000-100001000000,100001000003-999999999999"
remove 100001000000 -> "13-14"
remove 100001000000 -> "13-14,100001000003-999999999999"
add 100001000001 -> "13-14,100001000001-100001000001"
add 100001000001 -> "13-14,100001000001-100001000001,100001000003-999999999999"
remove 100001000001 -> "13-14"
add 100001000002 -> "13-14,100001000001-999999999999"
remove 100001000002 -> "13-14,100001000001-100001000001,100001000003-999999999999"
remove 100001000001 -> "13-14,100001000003-999999999999"
</pre>
</pre>