Re: dynamic variable definiton

• To: mathgroup at smc.vnet.net
• Subject: [mg67276] Re: dynamic variable definiton
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Thu, 15 Jun 2006 03:26:14 -0400 (EDT)
• Organization: The Open University, Milton Keynes, UK
• References: <e6opcl\$s4p\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```T.Sariyski wrote:
> Hi,
> I have a list of lists. The first element of each list is a description,
> the rest are numerical. Is it possible dynamic to create variable and to
> assign values to them? For example, I read data with ReadList:
>
>
> {{Face 1},{observ 0.1000E+02 0.3000E+01 0.4000E+01},{center 0.1050E+02
> 0.3000E+01 0.4000E+01},{e1 0.1000E+01 0.0000E+00 0.0000E+00},{e2
> 0.0000E+00 0.1000E+01 0.0000E+00},{e3 0.0000E+00 0.0000E+00
> 0.1000E+01},{v1 0.1050E+02 0.3500E+01 0.4500E+01},{v2 0.1050E+02
> 0.2500E+01 0.4500E+01},{v3 0.1050E+02 0.2500E+01 0.4000E+01},{v4
> 0.1050E+02 0.3500E+01 0.4000E+01}}
>
> I would like to have:
>
> Face=1;
> obsrv={0.1000E+02 , 0.3000E+01, 0.4000E+01};
> center={0.1050E+02, 0.3000E+01, 0.4000E+01};
> e1=... etc.
>
>
>
Ted,

Assuming that you really have a list of lists, you could use something
like the expression shown in In[2]"

In[1]:=
rawdata={{Face ,
1},{observ, 0.1000E+02, 0.3000E+01, 0.4000E+01},{center ,0.1050E+02, \
0.3000E+01,
0.4000E+01},{e1 ,0.1000E+01, 0.0000E+00 ,0.0000E+00},{e2 \
,0.0000E+00, 0.1000E+01, 0.0000E+00},{e3 ,0.0000E+00, 0.0000E+00, \
0.1000E+01},{v1 ,0.1050E+02, 0.3500E+01, 0.4500E+01},{v2 ,0.1050E+02, \
0.2500E+01, 0.4500E+01},{v3 ,0.1050E+02, 0.2500E+01, 0.4000E+01},{v4 \
,0.1050E+02, 0.3500E+01, 0.4000E+01}};

In[2]:=
((Evaluate[First[#1]] = If[Length[Rest[#1]] == 1,
Last[#1], Rest[#1]]) & ) /@ rawdata;

In[3]:=
{Face, observ, center, e1, e2, e3, v1, v2, v3, v4}

Out[3]=
{1, {2.27183, 1.81548, 2.08731},

{2.28542, 1.81548, 2.08731}, {1.27183, 0., 0.},

{0., 1.27183, 0.}, {0., 0., 1.27183},

{2.28542, 1.9514, 2.22323},

{2.28542, 1.67957, 2.22323},

{2.28542, 1.67957, 2.08731},

{2.28542, 1.9514, 2.08731}}

Regards,
Jean-Marc

```

• Prev by Date: Re: dynamic variable definiton
• Next by Date: Re: Determining continuity of regions/curves from inequalities
• Previous by thread: Re: dynamic variable definiton
• Next by thread: Re: dynamic variable definiton