Why equal(x[n], x[n..n])=0 ?

new topic     » topic index » view thread      » older message » newer message

Hi All,

I was debugging a function when I noticed that a slice with equal indexes is
different from an access with one index. x[n] is different from x[n..n] where n
is a valid index.
According to the manual, a slice always result in a sequence (also when x[n] is
an atom). But, in particular, when we have something like x[n..n], the result is
x[n] with the its depth incremented by 1. In other words, the structure of the
element depends on the access form (subscription or slicing). For me, this is a
surprising fact.
This kind of implementation affects some algorithms, because we have to test
when the indexes are equal in order to not use slice.
So, why equal(x[n], x[n..n])=0 ?

Regards,
   Fernando

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu