Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Replacement in a held function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113326] Re: Replacement in a held function
  • From: "István Zachar" <replicatorzed at gmail.com>
  • Date: Sat, 23 Oct 2010 07:08:19 -0400 (EDT)
  • References: <i9r81q$hq2$1@smc.vnet.net> <35a9220c-0de4-400e-be47-c739b715101c@u10g2000yqk.googlegroups.com>

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