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

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

Hi Fernando.
Maybe the point is that x[1..5] as well as x[3..3] are slices (two indexes
separated by two periods), while x[5] (a single index) is not a slice.
The simplest case: assume all elements of x are atoms. Then x[i] is an atom, and
x[i..j] is a sequence of atoms.
Assume also that you have this loop (code not tested):

x = repeat(4, 10)

for i = 10 to 1 by -1 do
   foo(x[1..i])
end for

The foo() procedure gets sequences with diminishing length, and processes them.
It expects it has to deal with a sequence.
But, oh surprise!, when you get to i = 1 (if x[n] where the same as x[n..n], as
you propose), it would get an atom!, and probably fail.
So, foo() should test if its argument is a sequence or an atom before
proceeding.
Don't you think this way things would be more complex?

Best regards.

PD: Hi Fernando.
I am from Buenos Aires, Argentina. I recall you are from Porto Alegre, Brazil,
true?
I understand enough Portuguese. You can contact me at ricardoforno at
tutopia.com in Portuguese if you like.
Ah! And I plan to take my holydays in the south of Brazil next January, with my
wife. Maybe we can meet then.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu