Base Method for isless on arrays or matrices


I was wondering if there is a method which compares each element of an array or matrix with another array or matrix or constant. I searched in methods(<), but I didn´t find anything.

Best regards,

In Julia most functions are defined on the “element” level, and you use broadcasting to apply them elementwise on arrays. For example:

julia> x = [1, 2, 3, 4];

julia> x .< 2
4-element BitArray{1}:

I know now, that it is possible to convert a and b with convert.(Bool, a) and then use c = a .& b.
Is there another maybe better way?

Thanks. I also came across it a few minutes ago, but I doesn´t know how to discard a post. But now I´m facing another similar problem. I would like to use the logical and function on i.e. to arrays:
a = [ 1 0 0 1]
b = [ 1 0 0 0]
c = a .&& b

I expect c to be [1 0 0 0].

Is there a method, which I can use for it?

Whoops, it looks like I approved those posts in the wrong order, so it’s my fault they’re jumbled. Sorry about that, Volker! Not that you’ve had two posts approved you’ll no longer need to wait in the queue.

Yes, your .& solution looks good!