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[], or .lexicographicPermute[]
// methods, but the condition in this program could be modified for different
// conditions easily.) The labeled "next" method makes this program run about
// 5.5 times faster due to faster bailout.
s = new set
upper = 7
n = new array[[upper], 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, eliasen@mindspring.com