# How to list functions and choose one at random?

**URL:** <https://community.thunkable.com/t/how-to-list-functions-and-choose-one-at-random/1584247>\
**Category:** Questions about Thunkable X\
**Tags:** lists, randomnumber, function\
**Created:** [October 27, 2021, 2:28pm UTC](https://community.thunkable.com/t/how-to-list-functions-and-choose-one-at-random/1584247 "2021-10-27T14:28:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![overshield](https://avatars.discourse-cdn.com/v4/letter/o/e19b73/32.png) [@overshield](https://community.thunkable.com/u/overshield)\
**Post date:** [October 27, 2021, 2:28pm UTC](https://community.thunkable.com/t/how-to-list-functions-and-choose-one-at-random/1584247/1 "2021-10-27T14:28:12Z")

</div>

I would like to be able to add certain functions to a list and randomly call one of them  
Is there a more dynamic way of doing this than my example below?

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/6/763fe882a7b9f0ef484f7462acc08a4cae9ce0af.png)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [October 27, 2021, 3:04pm UTC](https://community.thunkable.com/t/how-to-list-functions-and-choose-one-at-random/1584247/2 "2021-10-27T15:04:32Z")

</div>

If your functions are in a list then you need to call it using the **random** option instead of the **number** option.

Such as this:

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/4/f4c98888cb2c0c6a94077e56d65157ce92f06f96.png)

---

<div class="post-metadata">

**Author:** ![overshield](https://avatars.discourse-cdn.com/v4/letter/o/e19b73/32.png) [@overshield](https://community.thunkable.com/u/overshield)\
**Post date:** [October 27, 2021, 3:13pm UTC](https://community.thunkable.com/t/how-to-list-functions-and-choose-one-at-random/1584247/3 "2021-10-27T15:13:38Z")

</div>

How do you add functions to a list in the first place?

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [October 27, 2021, 3:28pm UTC](https://community.thunkable.com/t/how-to-list-functions-and-choose-one-at-random/1584247/4 "2021-10-27T15:28:24Z")

</div>

If you are interested in listing the function name then add them to the list. If in the other hand you want a block to execute a function as a parameter to that block then this is not yet available in Thunkable or at least I have no knowledge of it.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [October 27, 2021, 4:07pm UTC](https://community.thunkable.com/t/how-to-list-functions-and-choose-one-at-random/1584247/5 "2021-10-27T16:07:57Z")

</div>

No, this is the only way to call a random function from more than one option.

Another way to set this up would be to create just a single function with an input value and then pass the random number to the function. Within the function, you would still need the `if/elseif` blocks to determine the code to run for each input value. I’m not sure that’s an improvement!

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/7/3791f20466eab8fe446e8991e0168a538f8f88f8.png)

---

<div class="post-metadata">

**Author:** ![overshield](https://avatars.discourse-cdn.com/v4/letter/o/e19b73/32.png) [@overshield](https://community.thunkable.com/u/overshield)\
**Post date:** [October 27, 2021, 6:01pm UTC](https://community.thunkable.com/t/how-to-list-functions-and-choose-one-at-random/1584247/6 "2021-10-27T18:01:48Z")

</div>

Yes I was hoping to randomly choose one of the functions to execute it.

Thanks for the help guys

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 1:14pm UTC](https://community.thunkable.com/t/how-to-list-functions-and-choose-one-at-random/1584247/7 "2024-11-08T13:14:38Z")

</div>


