Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Probloem with Do and If' topicStudent Support Forum > General > "Probloem with Do and If"

Next Comment >Help | Reply To Topic
Author Comment/Response
Thibault
03/14/12 09:33am

Hi all,

In my program I have two list, M and L, where each value of the list refer to two others list, D and C.

I need to take the first value of M and I compare it with L, if M[[i]]<L[[j]] I must increment i and when M[[i]]==L[[j]], do Print[D[[i]]] and replace i with the value of j. And I continue but this time I need to print C[[i]]
I tried this but it doesn't work:

Do[If[M[[i]] < L[[j]], i++,
If[M[[i]] == L[[j]], Print[D[[i]]] && M /. i -> j],{j,10000}]

And I don't know how I can print the first time D[[i]],the seconde time C[[i]] then D[[i]].....

If someone can help me, I use mathematica 8 and I hope that all is clear.
Thanks for your answers

URL: ,

Subject (listing for 'Probloem with Do and If')
Author Date Posted
Probloem with Do and If Thibault 03/14/12 09:33am
Re: Probloem with Do and If Bill Simpson 03/14/12 4:08pm
Re: Re: Probloem with Do and If Thibault 03/19/12 10:01am
Re: Probloem with Do and If Bill Simpson 03/15/12 00:29am
Re: Probloem with Do and If Bill Simpson 03/19/12 2:14pm
Re: Re: Probloem with Do and If Thibault 03/20/12 11:25am
Next Comment >Help | Reply To Topic