Question: Using break to stop the entire computation


I would like to thank everyone who takes their time to respond to posts on this page. I have another question.

I have about 11 trillion lists that are of the form A shown below. The lists ofcourse have more elements than A (about 50 elements). What I want is to compute this value I call f, and the moment this value is found to be 1, we stop, and if all the values of f are 0, then we print(A). Here is my code, which has a problem and doesn't give me the result I want. How do I modify this so that if any value of f=1, then we stop, elif no 1 is found, we print just one value for A and not for every 0 produced?

A := [[1, 2], [1, 7], [5, 6], [1, 6], [1, 9], [6, 5], [9, 1], [2, 1], [7, 1], [6, 1], [5, 6]]; n := 9;
for i to n do for j to n do for k to nops(A) do if [i, j] = A[k] then a := Search([i, j], A); b := Search([j, i], A); if a < b then f := `mod`(b-a, 2); if f = 1 then break else print(A) end if end if end if end do end do end do;

Presently what I am doing is to Append all values of f into an Array and check that 1 is not an element of that Array. This is however very inconvenient since my lists are huge, and they are many, and we do not have to cpompute all the values of f once we come across a 1. Other than this, is there a way I can make my program run faster? Any suggestions are welcomed.



Please Wait...