Array question

Hey guys, Here is a fun problem for anyone that wants a challenge. I have a to arrays like this,

String command_string[] = {"up","down","turn left","turn right"}; String command_ext[] = {"look ","turn ","wattson ","and ","stop "};

I am trying to set up a condition that combines any element in the array, not just specific ones. Example: add_comm = command_string[] + command_ext[]; //add any of the elements together, not command_string[0]+command_ext[2], but, if any of the two strings are added together, then do something.

Any ideas? Thanks in advance for the help.


Thanks for the reply. Is there a way to make it list or use all of the elements instead of just the random one it picks?


I'm trying to call out all the elements in an array at once I guess, or list them all at the same time, and then compare all of them to a single command.

If you really want a solution, you may have to step back a little when you describe your problem instead of just describing your arbitrary solution. Things like "call out", "all at once", and "all at the same time" are a little vague, and don't really describe what you need to people here. It almost sounds like you want a regex solution, but I don't thing Arduinos have the power needed for that.

String command_string[] = {"up","down","turn left","turn right"}; 
String command_ext[] = {"look ","turn ","wattson ","and ","stop "};
add_comm = command_string[] + command_ext[]; //add any of the elements together, not

So you want 'add_comm' to be an array or string that contains every combination of an element from command_string followed by an element from command_ext? Like this?

"uplook upturn upwattson upand upstop downlook downturn downwattson downand downstop turn leftlook turn leftturn turn leftwattson turn leftand turn leftstop turn rightlook turn rightturn turn rightwattson turn rightand turn rightstop "

You can do that with loops but I don't see what good can be derived from such a string.

This looks interesting:

Here's another:

And here's a stacktrace topic:

In all cases, you feed this regular expression:

"(up|down|turn left|turn right)( (look|turn|wattson|and|stop))?"

into the grnerator, and it would build you some co … hang on - what's that "and" thing?

Perhaps you mean

"(((look|turn|wattson) (up|down|left|right))|stop)(and (((look|turn|wattson) (up|down|left|right)))|stop)*"

You can try out regexes here: