MathGroup Archive 2007

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

Search the Archive

Re: Assign delayed but fixed value

  • To: mathgroup at smc.vnet.net
  • Subject: [mg75216] Re: [mg75168] Assign delayed but fixed value
  • From: bsyehuda at gmail.com
  • Date: Sat, 21 Apr 2007 23:02:02 -0400 (EDT)
  • References: <200704190831.EAA04122@smc.vnet.net>

Hi,
you can make a combination of Set and SetDelayed
This way the set will take place only on the first call to var, and var will
not change anymore
var :=var = Table[Random[Integer,{0,3}],{param}]

now, the definition will not generate any warning
then
param=5
In[5]    var
Out[5]    {1, 0, 2, 1, 0}
In[6]    var
Out[6]    {1, 0, 2, 1, 0}

and if you chack the information stored for var
In[7]       ?var
Out[7]
var
var = {1, 0, 2, 1, 0}

regards
yehuda

On 4/19/07, zac <replicatorzed at gmail.com> wrote:
>
> Dear Group!
>
> My target is to define the value of 'var' in terms of the value of
> 'param'. The problem is that 'param' is introduced later than 'var',
> and this time-sequence cannot be changed. However, I would like to
> create 'var' such a way that IF 'param' is known, the value of 'var'
> should be the same any time it is called.
> Example code:
>
> In[1]:=
> var = Table[Random[Integer,{0,3}],{param}];
> param = 3;
>
> >From In[1]:= Table::iterb : Iterator {param} does not have appropriate
> bounds. More...
>
> In[3]:=
> var
>
> Out[3]=
> {1,1,3}
>
> In[4]:=
> var
>
> Out[4]=
> {0,3,1}
>
>
> The Table::iterb message is a secondary matter, as the two 'var'
> outputs do not equal, and this is my primary concern. Any idea how to
> solve this task? Thanks in advance.
>
> Istvan
>
>
>



  • Prev by Date: question
  • Next by Date: Re: neat way to program minimum of sum
  • Previous by thread: Re: Assign delayed but fixed value
  • Next by thread: Re: Assign delayed but fixed value