Re: Conversion Function -> List
- To: mathgroup at smc.vnet.net
- Subject: [mg44730] Re: [mg44726] Conversion Function -> List
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Mon, 24 Nov 2003 00:05:18 -0500 (EST)
- References: <200311220717.CAA21984@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On 22 Nov 2003, at 16:17, Vadim Zelenkov wrote: > Hello! > > Given a function > x y + Sin[x] Cos[y] > > I need to convert it into the list > {{x,y},{Sin[x],Cos[x]}} > > Generally, the purpose to convert a function > Sum[p[i,x] q[i[y], {i,1,n}] > > into the list > {{p[1,x],q[1,y]},...,{p[n,x],q[n,y]} > > How to do it using Mathematica? > > Thanks in advance! > > V.Z. > > P.S, If possible please duplicate your answers to > zelenkov[at]mail333.com > > There are lots of ways. here are just two: f[expr_] := expr /. {Plus -> List, Times -> List} So f[x*y + Sin[x]*Cos[y]] {{x, y}, {Cos[y], Sin[x]}} and f[x*y + Sin[x]*Cos[y] + Log[x]*Log[y]] {{x, y}, {Log[x], Log[y]}, {Cos[y], Sin[x]}} etc. Here is another way: g[expr_] := (Level[#1, 1] & ) /@ Level[expr, 1] g[x*y + Sin[x]*Cos[y]] {{x, y}, {Cos[y], Sin[x]}} and so on.... Andrzej Kozlowski Chiba, Japan http://www.mimuw.edu.pl/~akoz/
- References:
- Conversion Function -> List
- From: zelenkov@mail333.com (Vadim Zelenkov)
- Conversion Function -> List