Extend vector ops to boolean operators?

2012-03-06 Thread H. S. Teoh
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? T -- He who laughs last thinks slowest.

Re: Extend vector ops to boolean operators?

2012-03-06 Thread Timon Gehr
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? T Comparing arra

Re: Extend vector ops to boolean operators?

2012-03-06 Thread H. S. Teoh
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

Re: Extend vector ops to boolean operators?

2012-03-06 Thread Sean Cavanaugh
On 3/6/2012 2: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? T This same problem

Re: Extend vector ops to boolean operators?

2012-03-06 Thread Simen Kjærås
On Tue, 06 Mar 2012 21:35:11 +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 reas

Re: Extend vector ops to boolean operators?

2012-03-06 Thread Kapps
On Tuesday, 6 March 2012 at 20:28:40 UTC, 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?

Re: Extend vector ops to boolean operators?

2012-03-06 Thread James Miller
On 7 March 2012 10:58, Kapps wrote: > On Tuesday, 6 March 2012 at 20:28:40 UTC, 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[]); >> >>                ... >>        }

Re: Extend vector ops to boolean operators?

2012-03-06 Thread Peter Alexander
On Tuesday, 6 March 2012 at 23:57:07 UTC, James Miller wrote: On 7 March 2012 10:58, Kapps wrote: On Tuesday, 6 March 2012 at 20:28:40 UTC, H. S. Teoh wrote: It'd be really cool if I could do this:        void func(int[] vector, int[] bounds) {                assert(vector[] >= 0 && vector[]

Re: Extend vector ops to boolean operators?

2012-03-06 Thread James Miller
On 7 March 2012 15:35, Peter Alexander wrote: > On Tuesday, 6 March 2012 at 23:57:07 UTC, James Miller wrote: >> >> On 7 March 2012 10:58, Kapps wrote: >>> >>> On Tuesday, 6 March 2012 at 20:28:40 UTC, H. S. Teoh wrote: It'd be really cool if I could do this:        void

Re: Extend vector ops to boolean operators?

2012-03-06 Thread bearophile
James Miller: > What? I'm assuming you mean that you expect an array of `bool`s? Right. Vector operations like a[]>> from numpy import * >>> a = array([3,6,8,9]) >>> a == 6 array([False, True, False, False], dtype=bool) >>> a >= 7 array([False, False, True, True], dtype=bool) >>> a < 5 array([

Re: Extend vector ops to boolean operators?

2012-03-06 Thread James Miller
On 7 March 2012 17:03, bearophile wrote: > James Miller: > >> What? I'm assuming you mean that you expect an array of `bool`s? > > Right. Vector operations like a[] To see how this is useful you probably must think in terms of vector-style > programming. In NumPy the use of arrays of booleans is

Re: Extend vector ops to boolean operators?

2012-03-07 Thread Timon Gehr
On 03/06/2012 09:58 PM, H. S. Teoh wrote: 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[]);

Re: Extend vector ops to boolean operators?

2012-03-07 Thread Timon Gehr
On 03/06/2012 10:10 PM, Simen Kjærås wrote: On Tue, 06 Mar 2012 21:35:11 +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 wh