       Re: Help on iteration

• To: mathgroup at smc.vnet.net
• Subject: [mg54953] Re: [mg54942] Help on iteration
• From: Chris Chiasson <chris.chiasson at gmail.com>
• Date: Tue, 8 Mar 2005 05:03:38 -0500 (EST)
• References: <200503070710.CAA07720@smc.vnet.net>
• Reply-to: Chris Chiasson <chris.chiasson at gmail.com>
• Sender: owner-wri-mathgroup at wolfram.com

```does this help?

glist={{a,b,c,d,e,f,g,h,l,m,n,o,p,q,Date1},{a,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,
Date2},{a,R,s,t,u,v,X,Y,z,aa,bbb,cc,dd,tt,Date3}};
thefunc=ReleaseHold@Function@Evaluate@With[{checkposition=14},
If@@{Hold[#[[checkposition]]===0],
ReplacePart[#,(C-s)+Hold[zzz@Last@#],checkposition],#}]
Block[{tt=0},thefunc/@glist]

On Mon, 7 Mar 2005 02:10:26 -0500 (EST), Clifford Martin
<camartin at snet.net> wrote:
> I've got a simple problem I can't seem to get right.
> Here is a sample set of data
>
> glist={{a,b,c,d,e,f,g,h,l,m,n,o,p,q,Date1},
> {a,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,Date2},
> {a,R,s,t,u,v,X,Y,z,aa,bbb,cc,dd,tt,Date3}};
>
> What I want to do is look at the 14th element in each
> sublist. (For example in the above example data that
> would be values q, Q and tt). If any value is equal to
> zero (in my example lets say that tt =0) I want to
> 1.Check the date.
>  2.Pull a value associated with that date ,lets call
> it zzz. (that I've entered somewhere else and made a
> variable).
>   3. Calculate a new value for tt (non zero) using a
> calculation such as (s-C)+zzz.
>   4. Replace the value of tt(that was zero) with the
> new calculated value.
> 5. I want to do this for every list in my data set.
>
>   My actual case is a bit more complicated than this
> but if I can see how to do something like this I can
> probably figure out my problem. Thanks for any help.
>
> Cliff
>
>

--
Chris Chiasson
Kettering University
Mechanical Engineering