Re: Something very simple.....

• To: mathgroup at smc.vnet.net
• Subject: [mg87120] Re: Something very simple.....
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Tue, 1 Apr 2008 05:19:32 -0500 (EST)
• Organization: The Open University, Milton Keynes, UK
• References: <fssr6s\$biu\$1@smc.vnet.net>

```Steve Gray wrote:

> 1. I have a list of sphere centers and radii like this:
>
> sphlst={{{ 5.11,  0.76, -0.32}, 100.39},
> 	{{ 7.18, -1.86, -8.19},  98.02},
> 	{{26.71, -9.30, -6.85}, 111.27},
> 	{{    0,     0,     0}, 100.00},
> 	{{ 8.65,  4.28, -3.81}, 103.87}}.
>
> If I do Map[Sphere,sphlst] I get too many braces, like this:
>
> {Sphere[{{ 5.11,  0.76, -0.32}, 100.39}],
>  Sphere[{{ 7.18, -1.86, -8.19}, 98.02}],
>  Sphere[{{26.71, -9.30, -6.85}, 111.27}],
>  Sphere[{{    0,     0,     0}, 100.00}],
>  Sphere[{{ 8.65,  4.28, -3.81}, 103.87}]}
>
> and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5].
> What simple thing am I missing to remove the extra braces?
> (I know I can use Table but isn't there a "one-step" method?)
> Flatten doesn't seem to be useful here, or I'm using it wrong.

<snip>

The following will do it:

Map[Sphere[Sequence @@ #] &, sphlst]

For instance,

In[1]:= sphlst = {{{5.11, 0.76, -0.32},
100.39}, {{7.18, -1.86, -8.19}, 98.02}, {{26.71, -9.30, -6.85},
111.27}, {{0, 0, 0}, 100.00}, {{8.65, 4.28, -3.81}, 103.87}};

Map[Sphere[Sequence @@ #] &, sphlst]

Graphics3D@%

Out[2]= {Sphere[{5.11, 0.76, -0.32}, 100.39],
Sphere[{7.18, -1.86, -8.19}, 98.02],
Sphere[{26.71, -9.3, -6.85}, 111.27], Sphere[{0, 0, 0}, 100.],
Sphere[{8.65, 4.28, -3.81}, 103.87]}

[... graphic deleted ...]

Regards,
-- Jean-Marc

```

• Prev by Date: RE: Something very simple.....
• Next by Date: Re: Something very simple.....
• Previous by thread: Re: Something very simple.....
• Next by thread: Re: Something very simple.....