MathGroup Archive 2003

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

Search the Archive

RE: thanks for the help with list - extended syntax question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg40642] RE: [mg40617] thanks for the help with list - extended syntax question
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Sat, 12 Apr 2003 03:08:05 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

>-----Original Message-----
>From: Nathan Moore [mailto:nmoore at physics.umn.edu]
To: mathgroup at smc.vnet.net
>Sent: Friday, April 11, 2003 8:03 AM
>To: mathgroup at smc.vnet.net
>Subject: [mg40642] [mg40617] thanks for the help with list - extended syntax
>question
>
>
>Why is it in Mathematica that I can't operate on lists as if 
>they are long
>arrays(in the style of c)  It would be orders of magnitude 
>easier or me to
>just type,
>    data = {{x1,y1},{x2,y2}...{xn,yn}}
>and then find the desired sum like,
>    for(i=0,sum=0;i<;i++) { sum += data[[i,1]]*data[[i,2]]; }
>
>It seems idiotic that syntax like this (which most of the 
>scientific world
>would understand) is not allowed!  I hate learning new 
>(redundant) computer
>languages!!!
>
>Nathan
>
>

Nathan

In[4]:=
For[i = 1; sum = 0, i <= Floor[Length[d]/2], i++, 
    sum += d[[i, 1]]*d[[i, 3]]];
sum

Out[5]=
a1 c1 + a2 c2 + a3 c3 + a4 c4


Conceptionally this is 100% percent what you wanted. That (strange) syntax
you applied, is pure C, a low level implementation language from the ending
60's, only mastered by a minority of programmers, unknown to the scientific
world in near future. Not so Mathematica!

Tempora mutantur et nos mutamur in eos.

--
Hartmut Wolf



  • Prev by Date: RE: sum with lists
  • Next by Date: NDAESolve
  • Previous by thread: Re: thanks for the help with list - extended syntax question
  • Next by thread: Re: thanks for the help with list - extended syntax question