Re: [Phix Tutorial] Basic Sequence Actions
- Posted by euphoric (admin) Jan 27, 2019
- 1386 views
petelomax said...
It is (at least) logically consistent:
string s = "abcde" s[2..4] = '3' -- s is "a333e" (3 elements replaced) s[2..3] = '2' -- s is "a223e" (2 elements replaced) s[2..2] = '1' -- s is "a123e" (1 element replaced) s[2..1] = '0' -- s is "a123e" (0 elements replaced)
Ah, OK.
What does s[2..4] = "hello" do?
I'll guess that s = { 'a', "hello", 'e' } now.
"0 elements replaced" seems to be a non sequitur.
You can't "replace 0 elements." IOW, if the element doesn't exist, it can't be replaced.
Any "replacement" should always replace at least one element. A replacement means something is taken away and something takes its place. Otherwise, it's an insertion. And gap "replacements" aren't replacements... they are insertions. You're "inserting into the gap."
I wonder if the gap would be useful to OE.
Anyway, I'm not working for change; just wanting to make sure I understand and everything works optimally.