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: [mg113316] Re: Replacement in a held function
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sat, 23 Oct 2010 07:06:24 -0400 (EDT)

list == {};

func :== AppendTo[list, t];

Do[t == i; func; t ==., {i, 3}];

list

{1, 2, 3}


Bob Hanlon

---- "Istv=C3=A1n Zachar" <zac 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: Release dates for Mathematica versions
  • Next by Date: Variable number of arguments
  • Previous by thread: Replacement in a held function
  • Next by thread: Re: Replacement in a held function