Re: Why equal(x[n], x[n..n])=0 ?
- Posted by Fernando Bauer <fmbauer at hotmai?.com> Sep 25, 2007
- 698 views
Hi Jason. Thanks for your reply. Jason Gade wrote: > > 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". This is how slices are currently implemented in Euphoria, but it doesn't have to be. Why do you need the bucket? Why don't you catch the item directly? > 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. Yes, but taking the item out of the bucket consumes more time and energy! > > Does that make sense? Definitely yes. > > -- > 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. Regards, Fernando