Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: RE: simple problem with Map?!?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg49552] Re: [mg49496] RE: [mg49480] simple problem with Map?!?
  • From: DrBob <drbob at bigfoot.com>
  • Date: Fri, 23 Jul 2004 05:59:44 -0400 (EDT)
  • References: <200407220645.CAA20965@smc.vnet.net>
  • Reply-to: drbob at bigfoot.com
  • Sender: owner-wri-mathgroup at wolfram.com

Or...

d0={30,60,180,60,30};
d0/Tr@d0//N

{0.0833333,0.166667,0.5,0.166667,0.0833333}

Bobby

On Thu, 22 Jul 2004 02:45:07 -0400 (EDT), David Park <djmp at earthlink.net> wrote:

> Because you are mapping the function onto the elements when you really wany
> application to the entire list.
>
> d0 = {30, 60, 180, 60, 30};
>
> pppp = (N[#1/Plus @@ #1] & )[d0]
> {0.0833333, 0.166667, 0.5, 0.166667, 0.0833333}
>
> David Park
> djmp at earthlink.net
> http://home.earthlink.net/~djmp/
>
> From: Relishguy [mailto:relishguy at pluggedin.org]
To: mathgroup at smc.vnet.net
> To: mathgroup at smc.vnet.net
>
> I do not understand why the last evaluation ends up screwed:
>
> In[1]:= d0 = {30,60,180,60,30};
>
> In[2]:= tt = Plus @@ d0
> Out[2]= 360
>
> In[3]:= pp = N[d0 / tt]
> Out[3]= {0.0833333,0.166667,0.5,0.166667,0.0833333}
>
> In[4]:= ppp = N[d0 / (Plus @@ d0)]
> Out[4]= {0.0833333,0.166667,0.5,0.166667,0.0833333}
>
> In[5]:= pppp = N[# / (Plus @@ #)]& /@ d0
> Out[5]= {1.,1.,1.,1.,1.}
>
> Can anyone explain this simply? Do I need Hold[] or Evaluate[] somewhere?
>
> TIA.
>
> Regards..
>
>
>
>
>



-- 
DrBob at bigfoot.com
www.eclecticdreams.net


  • Prev by Date: [Bug] Transpose is broken for empty SparseArrays
  • Next by Date: Re: Simple Module Code
  • Previous by thread: RE: simple problem with Map?!?
  • Next by thread: RE: simple problem with Map?!?