# Making And\[\] and Or\[\] work with lists

**URL:** <https://community.wolfram.com/t/making-and-and-or-work-with-lists/16575>\
**Category:** Ideas\
**Tags:** logic\
**Created:** [August 14, 2020, 6:32pm UTC](https://community.wolfram.com/t/making-and-and-or-work-with-lists/16575 "2020-08-14T18:32:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![georgevw3](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/georgevw3/32/19010_2.png) [@georgevw3](https://community.wolfram.com/u/georgevw3)\
**Post date:** [August 14, 2020, 6:32pm UTC](https://community.wolfram.com/t/making-and-and-or-work-with-lists/16575/1 "2020-08-14T18:32:58Z")

</div>

Making And[] and Or[] work with lists

george woodrow

I often have a list of Boolean values that I want to see if they are all True, all False, etc. Unfortunately, And[] and Or[] do not work with lists:

```
In[1]:= And[{True, False, True}]

Out[1]= {True, False, True}

```

It needs the arguments to not be in a list:

```
In[2]:= And[True, False, True]

Out[2]= False

```

I tried a number of ways to make this work, but I came across an elegant solution:

```
In[3]:= ReplacePart[{True, False, True}, 0 -> And]

Out[3]= False

```

This works with an assigned list.

```
In[4]:= myBools1 = {True, True, True};
myBools2 = {True, False, True};

In[6]:= ReplacePart[myBools1, 0 -> And]

Out[6]= True

In[7]:= ReplacePart[myBools2, 0 -> And]

Out[7]= False

In[8]:= ReplacePart[myBools2, 0 -> Or]

Out[8]= True

```

This functionality is in the Generalizations part of the documentation for ReplacePart[], but I missed it, and perhaps others might miss it as well.

This trick also works with a lot of other functions.

[MakingAndWorkWithLists.nb](https://community.wolfram.com/uploads/short-url/xuIOqbrIWUVuVWBmJ3x7Ak7XyTx.nb) (8.23 KB)

---

<div class="post-metadata">

**Author:** ![rohitnamjoshi](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@rohitnamjoshi](https://community.wolfram.com/u/rohitnamjoshi)\
**Post date:** [August 14, 2020, 6:58pm UTC](https://community.wolfram.com/t/making-and-and-or-work-with-lists/16575/2 "2020-08-14T18:58:52Z")

</div>

Hi George,

Other ways to do this

```
And @@ {True, False, True}
(* False *)

AllTrue[{True, False, True}, Identity]
(* False *)

And[Evaluate[Sequence @@ {True, False, True}]]
(* False *)

Or @@ {True, False, True}
(* True *)

```

---

<div class="post-metadata">

**Author:** ![georgevw3](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/georgevw3/32/19010_2.png) [@georgevw3](https://community.wolfram.com/u/georgevw3)\
**Post date:** [August 14, 2020, 7:29pm UTC](https://community.wolfram.com/t/making-and-and-or-work-with-lists/16575/3 "2020-08-14T19:29:36Z")

</div>

Thanks – I’ll add them to my toolkit.
