Array operation with boolean operator

Andrea Fontana nospam at example.com
Thu Mar 14 11:56:27 PDT 2013


On Thursday, 14 March 2013 at 18:41:25 UTC, bearophile wrote:
> Andrea Fontana:
>
>> I always think X < Y return a single bool,
>
> Having a practice with NumPy and the like, I think X < Y as 
> returning as many bools as the length of X and Y:
>
>>>> from numpy import *
>>>> a = array([1, 5, 1])
>>>> b = array([1, 1, 5])
>>>> a < b
> array([False, False,  True], dtype=bool)
>
>
> Programmers with experience of Matlab, Matcad, etc, feel the 
> same.
>
> Bye,
> bearophile

But does sort!"a<b" still work if it returns an array?

It doesn't make sense for me :) if you ask me if a int vector is
lesser than another one I don't mean every single component but
the whole vector. Same goes for strings or any other range.


More information about the Digitalmars-d-learn mailing list