MathGroup Archive 2010

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

Search the Archive

Re: Replacement in a held function


Dear Valeri,

this is of course the trivial solution, though as I said, I cannot 
modify the signature of func, so I HAVE to rely on some pre-evaluation 
replacement method.

bests
Istvan

On 2010.10.22. 9:14, Valeri Astanoff wrote:
> On 22 oct, 07:39, István 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}
> Why not this way :
>
>   list = {};
> func[t_] := AppendTo[list, t];
> Do[func[i], {i, 3}];
> list
>
> {1, 2, 3}
>
>
>


  • Prev by Date: any thoughts on how to nondimensionlize my set of equations?
  • Next by Date: Re: FunctionQ?
  • Previous by thread: Re: Replacement in a held function
  • Next by thread: From list to list of arguments