Student Support Forum: 'Module: Binary List' topicStudent Support Forum > General > Archives > "Module: Binary List"

 Next Comment > Help | Reply To Topic
 Author Comment/Response Kurtis 01/28/11 1:46pm DotList[A_,B_,C_,D_,E_,F_]:= Module[{a=A,b=B,c=C,d=D,e=E,f=F}, q==1; For[j==0, j<=a, j++, For[k==0, k<=b, k++, For[l==0, l<=c, l++, For[m==0, m<=d, m++, Print[q,":.",{j,k,l,m}]&&q++; ];(*End D Loop*) ];(*End C Loop*) ];(*End B Loop*) ];(*End A Loop*) ](*End Module*) This will print the entire list of all possible 4-dot outcomes: 1:.{0,0,0,0} 2:.{0,0,0,1} 3:.{0,0,1,0} 4:.{0,0,1,1} 5:.{0,1,0,0} 6:.{0,1,0,1} 7:.{0,1,1,0} 8:.{0,1,1,1} 9:.{1,0,0,0} 10:.{1,0,0,1} 11:.{1,0,1,0} 12:.{1,0,1,1} 13:.{1,1,0,0} 14:.{1,1,0,1} 15:.{1,1,1,0} 16:.{1,1,1,1} I have been trying to figure out how to make it skip over certain sets and keep printing out the rest. Example: I do not want the module to print 4:.{0,0,1,1},7:.{0,1,1,0},and 12:.{1,0,1,1}. How can the list be printed without having to use an If[] statement with a Break[] and then setup another batch of For loops for each set that I do not want printed? URL: ,

 Subject (listing for 'Module: Binary List') Author Date Posted Module: Binary List Kurtis 01/28/11 1:46pm Re: Module: Binary List yehuda ben-s... 01/29/11 6:54pm
 Next Comment > Help | Reply To Topic