Akki wrote:
> Hi,
>
> How does one create a domain for a variable in Mathematica ?
>
> For e.g. x is a variable and I would like to create a domain for x
> consisting of 3, 5, 7 only.
> i.e. dom = {3,5,7} then use the condition \Element[x,dom]
>
> Thanks,
> Akki
>
Variables don't have domains as such, but you can create a variable that
contains a list that will act as a domain. Thus, suppose you have:
xdom={3,5,7};
then you can test if x is in that domain by using:
MemberQ[xdom,x]
It might be helpful if you described at slightly greater length what it
is you are trying to do - maybe with some code. For example, as written,
it is up to you to remember that xdom is the domain of x. If you were
dealing with many variables, it might be worth automating this so that
you could write something like withinDomain[x].
David Bailey
http://www.dbaileyconsultancy.co.uk