# Cut out list values greater than a number

**URL:** <https://cl.desmos.com/t/cut-out-list-values-greater-than-a-number/8849>\
**Category:** Questions\
**Tags:** desmos-calculator\
**Created:** [September 29, 2026, 4:48pm UTC](https://cl.desmos.com/t/cut-out-list-values-greater-than-a-number/8849 "2026-09-29T16:48:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Draki38](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/draki38/32/10831_2.png) [@Draki38](https://cl.desmos.com/u/Draki38)\
**Post date:** [September 29, 2026, 4:48pm UTC](https://cl.desmos.com/t/cut-out-list-values-greater-than-a-number/8849/1 "2026-09-29T16:48:21Z")

</div>

Any way to make a function that takes a list and a value and returns the list, but without entries larger than the value?

x = [5,15,25,35]

n = 21

f(x,n) = [5, 15]

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [September 29, 2026, 7:28pm UTC](https://cl.desmos.com/t/cut-out-list-values-greater-than-a-number/8849/2 "2026-09-29T19:28:20Z")

</div>

Lists can be filtered by conditions. In this case:

```auto
f(L,n) = L[L<n]

```

You don’t need `x` as a parameter if you don’t intend to use multiple lists in the function:

```auto
f(n) = x[x<n]

```

Or if you don’t intend to have different values for `n` either:

```auto
x_{filtered} = x[x<n]

```

---

<div class="post-metadata">

**Author:** ![Draki38](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/draki38/32/10831_2.png) [@Draki38](https://cl.desmos.com/u/Draki38)\
**Post date:** [October 5, 2026, 7:58pm UTC](https://cl.desmos.com/t/cut-out-list-values-greater-than-a-number/8849/3 "2026-10-05T19:58:07Z")

</div>

The problem with this is that it leaves behind undefined values. However, I discovered a solution that worked for my purposes.

f(L,n) = -(sort(-(L[L\<n])))[1]

While you cannot use min() or max() on lists with undefined values without it always returning undefined, you can use sort(). The goal of this was to get the max for me, so I was trying to get rid of the undefined values all together. However, this works as well.

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [October 5, 2026, 8:03pm UTC](https://cl.desmos.com/t/cut-out-list-values-greater-than-a-number/8849/4 "2026-10-05T20:03:16Z")

</div>

Would you mind sharing a graph keeping the undefined values? I don’t see that behavior, but maybe it’s just how I made my undefined values.

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/3/346492cba67b711d1811842248bcf06e38f0fa33.png)

---

<div class="post-metadata">

**Author:** ![Draki38](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/draki38/32/10831_2.png) [@Draki38](https://cl.desmos.com/u/Draki38)\
**Post date:** [October 5, 2026, 8:30pm UTC](https://cl.desmos.com/t/cut-out-list-values-greater-than-a-number/8849/5 "2026-10-05T20:30:06Z")

</div>

Huh, that’s really odd. Either I made a mistake, or the behavior has totally changed since last time I tried it. I can’t reproduce the issue I was having.

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [October 5, 2026, 9:44pm UTC](https://cl.desmos.com/t/cut-out-list-values-greater-than-a-number/8849/6 "2026-10-05T21:44:39Z")

</div>

Maybe if you were using greater than? Infinity shows as undefined, so if you include \<infinity in your condition (or \>-infinity), it filters those undefined elements out:

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/3/3f37b873573b51513760c8fcc2cb2f564d2f2f13.png)

---

<div class="post-metadata">

**Author:** ![Draki38](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/draki38/32/10831_2.png) [@Draki38](https://cl.desmos.com/u/Draki38)\
**Post date:** [October 8, 2026, 8:09pm UTC](https://cl.desmos.com/t/cut-out-list-values-greater-than-a-number/8849/7 "2026-10-08T20:09:47Z")

</div>

Found the issue. I was trying to take the maximum of an empty list and mistaking it returning undefined as there being undefined values in the list.
