Download or view multifortest2.frink in plain text format
/*
This attempts to generate all unique sets of up to 4 factors for products
less than a max - using the LABEL: multifor, next LABEL {level} statement.
However, when "next LABEL i" is executed none of the lower level indexes
are updated. Most critically, dependent lower bounds are not recalculated.
Is this the intended behavior? I would expect it be the same as a break
statement at level i+1, ie "skip the rest of level i+1", which would
increment level i and reset all lower levels.
The example program multinexttest.frink works because the bounds are
independent and the condition for the "next LABEL i" statement is only
triggered when index i changes.
If there are situations for both behaviors, I can only suggest:
next LABEL i updateLower=false
*or the desired default
*/
limit = 5
maxp = 11
LABEL:
multifor [fa, fb, fc, fd] = [new range[ 1, limit], new range[fa, limit],
new range[fb, limit], new range[fc, limit] ]
{
pf = [fa, fb, fc, fd]
prod = 1
for aa = 0 to 3
{
prod = prod * pf@aa
if prod > maxp
{
i = aa - 1
println["$pf > $maxp @$aa next $i"]
next LABEL i
}
}
println["$pf = $prod"]
}
/*
multifor [fa, fb, fc, fd] = [new range[ 1, limit], new range[ 1, limit],
new range[ 1, limit], new range[ 1, limit] ]
multifor [fa, fb, fc, fd] = [new range[ 1, limit], new range[fa, limit],
new range[fb, limit], new range[fc, limit] ]
*/
Download or view multifortest2.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 20139 days, 7 hours, 52 minutes ago.