multinexttest.frink

Download or view 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]
}
      


Download or view 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 19967 days, 12 hours, 24 minutes ago.