# Functions that return functions

**URL:** <https://cl.desmos.com/t/functions-that-return-functions/5138>\
**Category:** Discussion\
**Created:** [October 5, 2023, 1:31pm UTC](https://cl.desmos.com/t/functions-that-return-functions/5138 "2023-10-05T13:31:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve\_Heller](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/steve_heller/32/3539_2.png) [@Steve\_Heller](https://cl.desmos.com/u/Steve_Heller)\
**Post date:** [October 5, 2023, 1:31pm UTC](https://cl.desmos.com/t/functions-that-return-functions/5138/1 "2023-10-05T13:31:01Z")

</div>

I came across some fascinating code that I decided to refactor as a learning exercise:  
original: [Convex hull | Desmos](https://www.desmos.com/calculator/ffjf3jsgae)  
rewrite: [Convex hull simplified | Desmos](https://www.desmos.com/calculator/czzjpzphg6)

I chose this code cleanup exercise as a way to learn about Desmos coding and the coding style employed: functions that return functions, a powerful and compact approach. And, it finds convex hulls, which I’m curious about.

I eliminated a pile of seemingly dead code and greatly simplified what was left. I wonder if the discarded code had a function or if the simplified code has less functionality. These are academic questions as this is a learning exercise.

Does anyone know of other examples of using higher-order functions in Desmos code?

Thanks,  
Steve

---

<div class="post-metadata">

**Author:** ![sergeballif](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/sergeballif/32/231_2.png) [@sergeballif](https://cl.desmos.com/u/sergeballif)\
**Post date:** [October 8, 2023, 4:08pm UTC](https://cl.desmos.com/t/functions-that-return-functions/5138/2 "2023-10-08T16:08:47Z")

</div>

I don’t have much to add, but I just wanted to say what a cool graph it is and that both the code and graph were a lot of fun to play with.
