calling a random function number

I have a recurring problem that when I'm controlling leds, I make several different functions for different fx and just want to trigger them randomly but having a hard time to formulate it in an intelligent way and end up hardcoding every function call.

ex: I have let's say 10 functions called anim1();, anim2();, anim3(); etc and would like to called them randomly in that fashion :

randNumber = random(1,11);
anim[randNumber]();

I know that it's not that type of brackets I need to use but I can't find the proper syntax and I'm wondering if it's possible to do that.. I'm sure there must be a way :wink:

thanks for your help

carapace:
ex: I have let's say 10 functions called anim1();, anim2();, anim3(); etc and would like to called them randomly in that fashion :

If the parameter lists of all functions are the same (i.e. no parameters at all) you could use an array of function pointers to holf the function addresses and call the functions by index in the arry.

Or, use a switch/case statement to call the appropriate function. Put the switch/case in a function that takes the random number, so calling it is simple:

   pickFunctionToExecute(theRandomNumber);
typedef void (*aniFunc)();

void printAnim(byte number) {
  Serial.print(F("Anim "));
  Serial.println(number);
}

void ani_1() {
  printAnim(1);
}
void ani_2() {
  printAnim(2);
}
void ani_3() {
  printAnim(3);
}
void ani_4() {
  printAnim(4);
}
void ani_5() {
  printAnim(5);
}
void ani_6() {
  printAnim(6);
}
void ani_7() {
  printAnim(7);
}
void ani_8() {
  printAnim(8);
}
void ani_9() {
  printAnim(9);
}
void ani_10() {
  printAnim(10);
}

aniFunc table[10] = { ani_1, ani_2, ani_3, ani_4, ani_5, ani_6, ani_7, ani_8, ani_9, ani_10 };

unsigned long topLoop;

void setup() {
  Serial.begin(115200);
}
void loop() {
  static unsigned long lastSecond;
  topLoop = millis();
  if (topLoop - lastSecond >= 1000) {
    lastSecond = topLoop;
    (*table[random(10)])();
  }
}
Anim 8
Anim 10
Anim 4
Anim 9
Anim 1
Anim 3
Anim 5
Anim 9
Anim 4
Anim 10
Anim 1

Building on Whandall's example, if your functions do not need to be called elsewhere (outside of the array), or are relatively short, an array of lambdas may suffice:

typedef void (*aniFunc)();

void printAnim(byte number) {
  Serial.print(F("Anim "));
  Serial.println(number);
}

aniFunc table[3] = {
  [](){ printAnim(1); },
  [](){ printAnim(2); },
  [](){ printAnim(3); }
};

unsigned long topLoop;

void setup() {
  Serial.begin(115200);
}
void loop() {
  static unsigned long lastSecond;
  topLoop = millis();
  if (topLoop - lastSecond >= 1000) {
    lastSecond = topLoop;
    table[random(3)]();
  }
}