Loops
- forall
-
forall(f in FAC, t in TIME) make(f,t) <= MAXCAP(f,t) forall(t in TIME) do use(t) <= MAXUSE(t) buy(t) <= MAXBUY(t) end-do
- with
-
equivalent to a
forall loop stopped after the first iteration
with f='F1', t=1 do make(f,t) <= MAXCAP(f,t) end-do
- while
-
i := 1 while (i <= 10) do write(' ', i) i += 1 end-do
- repeat ... until
-
i := 1 repeat write(' ', i) i += 1 until (i > 10)
- break, next
-
- break jumps out of the current loop
- break n jumps out of n nested loops (where n is a positive integer)
- next jumps to the beginning of the next iteration of the current loop
- use break 'looplabel' and next 'looplabel' with labeled loops:
'L1': repeat 'L2': while (condition1) do if condition2 then break 'L1' end-if end-do until condition3
- counter
-
- Use the construct as counter to specify a counter variable in a bounded loop (i.e., forall or aggregate operators such as sum). At each iteration, the counter is incremented
cnt:=0.0 writeln("Average of odd numbers in 1..10: ", (sum(cnt as counter, i in 1..10 | isodd(i)) i) / cnt)
© 2001-2020 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.