Re: Why equal(x[n], x[n..n])=0 ?
- Posted by CChris <christian.cuvier at agricult?re.gouv.f?> Sep 25, 2007
- 719 views
Jason Gade wrote: > > Maybe you could post an algorithm/code sample where you think returning an > atom > would make more sense? > > s[constant...constant] is never used; slices are usually used in a loop or > with > one or two variables. The expression following almost invariably expects a > sequence--returning > either a sequence or an atom would require extra checking. > > -- > 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. I have some code that normalises a sequence of numbers and pairs of numbers to make the whole stuff non overlapping and increasing. I remember having run in this sort of trouble, where I have a lower and upper limit, and the idea is: return element of sequence if lower=upper, and keep working on a smaller slice else. And I got hit precisely by the fact that s[lower..upper] has a bucket around it. I can dig the code up when I'm back home tonight (ie 10-12h from now). While it is indeed annoying at times, I think it is better that slices always be sequence, because not doing so would make quite more code more complex. But I do agree that this is sometimes a nuisance. CChris