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

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

Sorry, I missed the second part of the post.

Fernando Bauer wrote:
> 
> Yes. The manual is also very clear about this. However, the meaning of my
> question
> is another:
> Why does Euphoria (the manual) define slices like x[n..n] and x[n]
> differently?
> Why is an atom transformed in a sequence by using a slice?
> 
> An analogy:
> Suppose you have a set of enumerated objects and the following rules:
> a)You can hold only one at a time. (subscription)
> b)If you need more objects you can use a container. (slicing)
> Then, if someone asks you to collect the objects 2 to 4?
>  - Because the number of objects is 3, you need to use the container (rule 2).
> Now, if someone asks you to collect the objects 2 to 2?
>  - Because the number of objects is 1, you *don't* need to use the container,
> you can catch it directly (rule 1). Besides, if you use the container
> (sequence),
> you will have to discard it to catch the object (an unnecessary procedure).
> Regards,
>    Fernando

Because when you say s[3..3] you are saying, "bring me one item in a bucket".
It's not mutually exclusive. You can carry one thing with or without the bucket.
You can always take the item out of the bucket after it is brought to you.

Does that make sense?

--
A complex system that works is invariably found to have evolved from a simple
system that works.
--John Gall's 15th law of Systemantics.

"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare

j.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu