1. [Phix] Splicing Anomaly ( resolved )
- Posted by _tom (admin) Jan 17, 2019
- 961 views
A splice "joins ends together."
You can not splice an atom because it has no ends!
This example is Phix only. (oE requires slice lengths to be the same.)
sequence s s = { 0, 5 , 5 , 0 } s[2..1] = {99} ? s -- {0,99,5,5,0} s = { 0, 5 , 5 , 0 } -- Warning! s[2..1] = 99 ? s s = { 0, 5 , 5 , 0 } s[2..2] = 99 ? s s = { 0, 5 , 5 , 0 } s[2..3] = 99 ? s -- {0,5,5,0} -- {0,99,5,0} -- {0,99,99,0}
The patterns are ok.
The "problem" is that trying to splice an atom fails quietly. The atom value just disappears without warning.
_tom
2. Re: [Phix] Splicing Anomaly
- Posted by petelomax Jan 17, 2019
- 972 views
Don't understand. Line 4 only works on phix. Delete that line and I get exactly the same answers from phix and OE.
Line 4 was asking to replace an empty slice with a non-empty one, and that is precisely what it does.
Consecutively, the slice = atom lines are asking to replace 0, then 1, then 2 elements, and that is precisely what it does.
Perhaps it helps if you think of slice = atom as being shorthand for slice = repeat(atom,<implied_length_of_slice>)?
3. Re: [Phix] Splicing Anomaly
- Posted by _tom (admin) Jan 17, 2019
- 946 views
sequence s s = { 0, 5 , 5 , 0 } -- Warning! s[2..1] = 99 ? s -- {0,5,5,0} -- ? length(99) -- ^ incompatible type for routine signature -- 1 // for oE ? s[2..1] -- {}
Same result in oE and Phix
Where does the `99` go?
I would expect a warning that the `99` has vanished into a black hole.
_tom
4. Re: [Phix] Splicing Anomaly
- Posted by petelomax Jan 17, 2019
- 940 views
You could say the same about
?repeat(99,0)
5. Re: [Phix] Splicing Anomaly
- Posted by _tom (admin) Jan 17, 2019
- 941 views
Effectively I have written
{} = 99
Which is the standard "vanishing" syntax.
So my problem was, Phix is doing what it always does, but the result was clouded by some syntax.
_tom