multinexttest.frink

View or download multinexttest.frink in plain text format


// This tests the labeled "next" for multifor which gives a level to jump to.
// This program demonstrates bailing out of multifor loops with labeled
// next statements.  It generates only unique lists of numbers.  (This could
// be generated efficiently with the array.permute[] method, but the condition
// in this program could be modified for different conditions easily.)

s = new set

upper = 7
n = new array
for i=1 to upper
   n.push[new range[1,upper]]
   
LOOP:
multifor a = n
{
   len = length[a]
   for i=0 to len-1
      if s.contains[a@i]  // Duplicates found in output?
      {
         s.clear[]
         next LOOP i      // Demonstrates labeled next, jump to next level i
      } else
         s.put[a@i]

   s.clear[]      

   println[a]
}
      


View or download multinexttest.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 17536 days, 5 hours, 48 minutes ago.