MathGroup Archive 2005

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

Search the Archive

Re: Help on iteration


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
Graduate Student
1 810 265 3161


  • Prev by Date: Re: Outputing a tabular function
  • Next by Date: Re: Outputing a tabular function
  • Previous by thread: Help on iteration
  • Next by thread: Re: Help on iteration