MathGroup Archive 2009

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

Search the Archive

Re: For loops with mathematica....

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101125] Re: [mg101069] For loops with mathematica....
  • From: "David Park" <djmpark at comcast.net>
  • Date: Wed, 24 Jun 2009 06:36:02 -0400 (EDT)
  • References: <12783446.1245755769407.JavaMail.root@n11>

It would help if you could give us more of a specific simple example.

If you are completely new to Mathematica you probably have to build up from
simpler problems.

If you look at Table you will see that in one form you can specify a
specific list of iterator values: {i,{20,200,300}} gives those three values.

You might want to write a function with parameters that uses a Module to
build up a calculation. For example, maybe something like this is what you
want:

f[p1_, p2_][i_] :=
 Module[{work},
  work = i + p1;
  work^2 + p2]

Table[f[1, 2][i], {i, {20, 200, 300}}]
{443, 40403, 90603}


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/  


From: Julien [mailto:jderr at cgr.harvard.edu] 

Hey guys, 

I am totally new to mathematica.
I want to use a simple loop for but with many arguments in the loop...
the help says to do

Do[ thingstodo, {i,8}]

i will go from 1 to 8 to do thingstodo.

First question: what if I want i to go from 20 then 200 then 300 then 400,
(can we give a sequence as argument?)

Second question: I have a lot of line to do in things to do. should I
separate everything with a ; (doesn t seem to work, or use a procedure or
something?)


THanks a lot for your help!!!

Julien




  • Prev by Date: Re: FindInstance over Integers
  • Next by Date: Re: Re: from the list select
  • Previous by thread: Re: For loops with mathematica....
  • Next by thread: Re: For loops with mathematica....