# Base Method for isless on arrays or matrices

**URL:** https://discourse.julialang.org/t/base-method-for-isless-on-arrays-or-matrices/24424
**Category:** General Usage
**Created:** [May 21, 2019, 12:08pm UTC](https://discourse.julialang.org/t/base-method-for-isless-on-arrays-or-matrices/24424 "2019-05-21T12:08:32Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Volker](https://avatars.discourse-cdn.com/v4/letter/v/77aa72/32.png) [@Volker](https://discourse.julialang.org/u/Volker)
#### Post date: [May 21, 2019, 12:08pm UTC](https://discourse.julialang.org/t/base-method-for-isless-on-arrays-or-matrices/24424/1 "2019-05-21T12:08:32Z")

</div>

Hello,

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,  
Volker

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [May 21, 2019, 12:17pm UTC](https://discourse.julialang.org/t/base-method-for-isless-on-arrays-or-matrices/24424/2 "2019-05-21T12:17:56Z")

</div>

> [@Volker](#):
>
> each element

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

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

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

```

---

<div class="post-metadata">

### Author: ![Volker](https://avatars.discourse-cdn.com/v4/letter/v/77aa72/32.png) [@Volker](https://discourse.julialang.org/u/Volker)
#### Post date: [May 21, 2019, 12:52pm UTC](https://discourse.julialang.org/t/base-method-for-isless-on-arrays-or-matrices/24424/3 "2019-05-21T12:52:04Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Volker](https://avatars.discourse-cdn.com/v4/letter/v/77aa72/32.png) [@Volker](https://discourse.julialang.org/u/Volker)
#### Post date: [May 21, 2019, 12:52pm UTC](https://discourse.julialang.org/t/base-method-for-isless-on-arrays-or-matrices/24424/4 "2019-05-21T12:52:17Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)
#### Post date: [May 21, 2019, 12:55pm UTC](https://discourse.julialang.org/t/base-method-for-isless-on-arrays-or-matrices/24424/5 "2019-05-21T12:55:43Z")

</div>

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!
