STACK: Restrict input to a given set of variable names

STACK: Restrict input to a given set of variable names

by Martin Kraska -
Number of replies: 2

How can I restrict algebraic input to a given set of variables, i.e. refuse any other input at validation level?

Background is that I ask for an expression in N, l, E and A and get results such as Nl/EA, with the students assuming implicit multiplication between the characters. I could add asterisks for this particular question, yet I don't want the students to get used to this, because I will not always have single character names.


Average of ratings: -
In reply to Martin Kraska

Re: STACK: Restrict input to a given set of variable names

by Stephan Bach -
Not a very elegant solution, but you could write all combinations (or actually arrangements) of two variables in the "Forbidden words".
In reply to Stephan Bach

Re: STACK: Restrict input to a given set of variable names

by Martin Kraska -
This might explode, because you can't rely on products of just two variables in the answer. I think I need a sort of input training in the beginning of each course.