Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Something very simple.....

  • To: mathgroup at smc.vnet.net
  • Subject: [mg87119] Re: [mg87103] Something very simple.....
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Tue, 1 Apr 2008 05:19:21 -0500 (EST)
  • References: <200804010819.DAA11874@smc.vnet.net>

Just use Apply with level specification {1}:

Apply[Sphere, sphlst, {1}]

{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]}

Andrzej Kozlowski


On 1 Apr 2008, at 10:19, 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.
>
> 2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}.
> I want the elements of lsta that do NOT correspond to elements
> of lstb, in this case everything from lsta except elements
> 1,3, and 4: result={b,e,f}.
> (lstb won't have entries larger than Length[lsta]).
>
> Thanks for any tips.
>
> Steve Gray
>



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