MathGroup Archive 2010

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

Search the Archive

Re: Replacement in a held function


Something like this...

list = {};
func := AppendTo[list, t];
Do[Block[{t = i}, func], {i, 3}];
list


On 22 Oct, 06:39, Istv=E1n Zachar <z... at freemail.hu> wrote:
> Dear Group,
>
> How can the following toy example be modified to yield {1, 2, 3}
> instead of {t, t, t}? Suppose func, t and list are given parameters
> that cannot be changed, so I want to solve it with some kind of
> argument-replacement-inside-the-loop method. Thus I'm looking for a
> solution which only manipulates the internals of Do. If it is possible
> at all.
>
> In[104]:= list = {};
> func := AppendTo[list, t];
> Do[func /. {t -> i}, {i, 3}];
> list
>
> Out[107]= {t, t, t}



  • Prev by Date: Re: From list to list of arguments
  • Next by Date: Re: Replacement in a held function
  • Previous by thread: Re: Replacement in a held function
  • Next by thread: Re: Replacement in a held function