1. [Phix] Splicing Anomaly ( resolved )

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

new topic     » topic index » view message » categorize

2. Re: [Phix] Splicing Anomaly

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>)?

new topic     » goto parent     » topic index » view message » categorize

3. Re: [Phix] Splicing Anomaly

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

new topic     » goto parent     » topic index » view message » categorize

4. Re: [Phix] Splicing Anomaly

You could say the same about

?repeat(99,0) 
new topic     » goto parent     » topic index » view message » categorize

5. Re: [Phix] Splicing Anomaly

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

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu