# Add clip() utility function to Base

**URL:** <https://discourse.julialang.org/t/add-clip-utility-function-to-base/1690>\
**Category:** General Usage\
**Tags:** proposal\
**Created:** [January 25, 2017, 9:39pm UTC](https://discourse.julialang.org/t/add-clip-utility-function-to-base/1690 "2017-01-25T21:39:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [January 25, 2017, 9:39pm UTC](https://discourse.julialang.org/t/add-clip-utility-function-to-base/1690/1 "2017-01-25T21:39:55Z")

</div>

In Python this is a handy operation on arrays:

[https://docs.scipy.org/doc/numpy/reference/generated/numpy.clip.html](https://docs.scipy.org/doc/numpy/reference/generated/numpy.clip.html)

Is there a function in Julia for achieving the same result? If not, can I open an issue on GitHub with a feature request?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [January 25, 2017, 9:42pm UTC](https://discourse.julialang.org/t/add-clip-utility-function-to-base/1690/2 "2017-01-25T21:42:20Z")

</div>

Perhaps this is what you are looking for

```julia
help?> clamp
search: clamp clamp!

  clamp(x, lo, hi)

  Return x if lo <= x <= hi. If x < lo, return lo. If x > hi, return hi.
  Arguments are promoted to a common type. Operates elementwise over x if x is
  an array.

```

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [January 25, 2017, 9:48pm UTC](https://discourse.julialang.org/t/add-clip-utility-function-to-base/1690/3 "2017-01-25T21:48:34Z")

</div>

Perfect, I still don’t understand how can I mark questions as solved on Discourse, sometimes I have the option, sometimes I don’t. Do I need to tag the thread with `question`?

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [January 26, 2017, 3:29am UTC](https://discourse.julialang.org/t/add-clip-utility-function-to-base/1690/4 "2017-01-26T03:29:46Z")

</div>

@kristoffer.carlsson how to mark the question as solved? I want to mark it myself next time.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [January 26, 2017, 7:43am UTC](https://discourse.julialang.org/t/add-clip-utility-function-to-base/1690/5 "2017-01-26T07:43:21Z")

</div>

Well, I didn’t mark anything so I thought you did. Maybe someone with mod power did. I’m not sure how to mark as solution, I thought there was a button under each post you could click.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [January 26, 2017, 3:16pm UTC](https://discourse.julialang.org/t/add-clip-utility-function-to-base/1690/6 "2017-01-26T15:16:22Z")

</div>

Sorry, I think it was @ihnorton that marked it? I got a notification in the upper right saying that my post was edited by him. Only admin can mark as solved?

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [January 26, 2017, 3:19pm UTC](https://discourse.julialang.org/t/add-clip-utility-function-to-base/1690/7 "2017-01-26T15:19:20Z")

</div>

I created a new topic for this question, it turns out it is important:

> [@How to mark a question as solved?](https://discourse.julialang.org/t/how-to-mark-a-question-as-solved/1703):
>
> Sometimes I see the checkbox below the answers, sometimes I don’t. Can you elaborate on how discourse decides on that?
