Extend vector ops to boolean operators?

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Mar 6 12:58:38 PST 2012


On Tue, Mar 06, 2012 at 09:35:11PM +0100, Timon Gehr wrote:
> On 03/06/2012 09:30 PM, H. S. Teoh wrote:
> >It'd be really cool if I could do this:
> >
> >	void func(int[] vector, int[] bounds) {
> >		assert(vector[]>= 0&&  vector[]<  bounds[]);
> >		...
> >	}
> >
> >Is there any reason why we shouldn't implement this?
[...]
> 
> Comparing arrays already does lexical-style comparison (which makes sense).

What I wanted is not lexicographic comparison, but per-element
comparison:

	v[]>=0   means  v[0]>0 && v[1]>0 && v[2]>0 && ...
	v[]<b[]  means  v[0]<b[0] && v[1]<b[1] && v[2]<b[2] && ...

as opposed to lexicographical:

	v < b  means  (v[0]!=b[0]) ? v[0]<b[0] :
			(v[1]!=b[1]) ? v[1]<b[1] :
			(v[2]!=b[2]) ? v[2]<b[2] :
			...


T

-- 
This is not a sentence.


More information about the Digitalmars-d mailing list