Calling functions based on serial input

I have a list of functions and would like to call them by typing the function name into the serial monitor. This is a snippet of the code:

while(!Serial.available()){
}
input = Serial.readString();
input();

If someone types "red", then input = "red". This part works. What I now want is for it to call red() without writing an if statement (since I have so many functions it would take a lot of ifs). All functions follow this format:

void red(){
  digitalWrite(redPin, HIGH);
}

What I now want is for it to call red() without writing an if statement

Once you code is compiled all names are lost so the function red() will not exist at run time, so you can not substitute what you type for a function.

You could do this with some types of interpreted language but C is not one of these.

Darn... thanks for the quick reply.

The simplest way to achieve it would be with a switch statement something like this

String input;
char commands[3][6]={"red","green","blue"};
int n;

while(!Serial.available()){
}
input = Serial.readString();

for (n=0;n<3;n++)
  if(input==commands[n])
  switch(n)
    {
    case 1:red();break;
    case 2:green();break;
    case 3:blue();break;
   }

Although, personally, I’d rather go with a char array for my input, and then use strcmp (instead of the ==) but this would make your Serial.read slightly more complex.