Grasshopper

algorithmic modeling for Rhino

Hi guys,

Asuming I have a list of numbers , I want to get the result of the mass multiplication of them ,what should I do ?? I cant write script myself ,so I am looking for help here .Thanks in advance...

Views: 927

Replies to This Discussion

So you mean just take a list of numbers like 1,2,3,4 and get 1*2*3*4 ?
if so, then something like this should do it (with the input set to List Access):

private void RunScript(List<double> x, ref object A)
{
double MassMultiply = 1;
for (int i = 0; i < x.Count; i++)
{
MassMultiply *= x[i];
}
A = MassMultiply;
}
Thanks Dan!!

This is what I need!
And say I have a set of numbers like 1,2,3,4,5
Is it possible to get a list of results 1,1*2,1*2*3,1*2*3*4,1*2*3*4*5 ??
Hi Alpha,

then now this is similar to what Daniel suggested, but you store the partial results:private void RunScript(List<double> x, ref object A)
{
   double massMultiply = 1;
   double[] interim = new double[x.Count]; //array of doubles

   for (int i = 0; i < x.Count; i++)
   {
      massMultiply *= x[i];
      interim[i] = massMultiply;
   }

   A = massMultiply;
   B = interim;
}


- Giulio
______________
giulio@mcneel.com
McNeel Europe, Barcelona
Thanks Giulio !! This is what I am after ,hah.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service