# Is there a function to clip an array to a maximum value? e.g. set values in an arr

**URL:** <https://discourse.julialang.org/t/is-there-a-function-to-clip-an-array-to-a-maximum-value-e-g-set-values-in-an-arr/56412>\
**Category:** General Usage\
**Created:** [March 3, 2021, 3:19pm UTC](https://discourse.julialang.org/t/is-there-a-function-to-clip-an-array-to-a-maximum-value-e-g-set-values-in-an-arr/56412 "2021-03-03T15:19:17Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [March 3, 2021, 6:00pm UTC](https://discourse.julialang.org/t/is-there-a-function-to-clip-an-array-to-a-maximum-value-e-g-set-values-in-an-arr/56412/4 "2021-03-03T18:00:32Z")

</div>

> [@rdeits](#):
>
> Yup, it’s called `clamp!`

I wonder why we kept the `clamp!` function, given that it seems equivalent to

```julia
array .= clamp.(array, lo, hi)

```

Probably it was just an oversight that it didn’t get removed when we removed the other vectorized functions in favor of dot calls?

---

_[View the full topic](https://discourse.julialang.org/t/is-there-a-function-to-clip-an-array-to-a-maximum-value-e-g-set-values-in-an-arr/56412)._
