Re: Symbols in expression
- To: mathgroup at smc.vnet.net
- Subject: [mg89098] Re: Symbols in expression
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Sun, 25 May 2008 06:27:24 -0400 (EDT)
- References: <200805250722.DAA18957@smc.vnet.net>
On 25 May 2008, at 16:22, sigmundv at gmail.com wrote:
> Dear all,
>
> Define, say,
>
> r = {Cos[u] Sin[v],Sin[u] Sin[v],Cos[v]}.
>
> How can I write a function, which takes r as an argument and returns a
> list {u,v}? If we defined r[u_,v_]:=... it could be achieved fairly
> easily using DownValues. But how can I achieve it in this case?
>
> Kind regards,
> Sigmund Vestergaard
>
Your question is far from clear, but this pehraps might be what you
are lookign for:
r = {Cos[u] Sin[v], Sin[u] Sin[v], Cos[v]};
Union[Cases[r, _Symbol?(Not[NumericQ[#]] &), {-1}]]
{u, v}
The Not[NumericQ[#]] & part is needed in case you r was something like:
r = {Cos[2Pi u] Sin[2Pi v], Sin[2Pi u] Sin[2Pi v], Cos[2 Pi v]};
Andrzej Kozlowski
- References:
- Symbols in expression
- From: sigmundv@gmail.com
- Symbols in expression