Assume the loop:Just a correction of the subject, it should be: How to exit from "for t *of* C when f(t) loop ? -reinert
for t of C loop
if f(t) then
do something....
elsif f(t) > f1 then
exit;
end if;
end loop;
I would like to simplify this construct (somehow) like this:
for t of C when f(t) loop
do something....
end loop;
However, this is not computationally effective, since t in this case runs through the whole C.
Any ideas for a compromise?
reinert
mandag 23. oktober 2023 kl. 07:03:01 UTC+2 skrev reinert:Normally one does something
Assume the loop:
for t of C loop
if f(t) then
do something....
elsif f(t) > f1 then
exit;
end if;
end loop;
I would like to simplify this construct (somehow) like this:
for t of C when f(t) loop
do something....
end loop;
However, this is not computationally effective, since t in this case runs through the whole C.
Any ideas for a compromise?
reinertJust a correction of the subject, it should be: How to exit from "for t *of* C when f(t) loop ? -reinert
On Monday, October 23, 2023 at 6:04:30 PM UTC+11, reinert wrote:
mandag 23. oktober 2023 kl. 07:03:01 UTC+2 skrev reinert:
Assume the loop:
for t of C loop
if f(t) then
do something....
elsif f(t) > f1 then
exit;
end if;
end loop;
I would like to simplify this construct (somehow) like this:
for t of C when f(t) loop
do something....
end loop;
However, this is not computationally effective, since t in this case runs through the whole C.
Any ideas for a compromise?
Normally one does somethingreinertJust a correction of the subject, it should be: How to exit from "for t *of* C when f(t) loop ? -reinert
t := C'first;
loop
do something...
exit when Condition;
t := t + 1;
end loop;
The conditon is just a boolean expression. It can be as simple or as complicated as one desires.
I would like an exit possibility somehow like this:
for t of C when f(t), but exit when f(t) loop
do something....
end loop;
Three lines less - keeping errors down :-)
reinert
onsdag 25. oktober 2023 kl. 04:32:58 UTC+2 skrev :
On Monday, October 23, 2023 at 6:04:30 PM UTC+11, reinert wrote:
mandag 23. oktober 2023 kl. 07:03:01 UTC+2 skrev reinert:
Assume the loop:
for t of C loop
if f(t) then
do something....
elsif f(t) > f1 then
exit;
end if;
end loop;
I would like to simplify this construct (somehow) like this:
for t of C when f(t) loop
do something....
end loop;
However, this is not computationally effective, since t in this case runs through the whole C.
Any ideas for a compromise?
Normally one does somethingreinertJust a correction of the subject, it should be: How to exit from "for t *of* C when f(t) loop ? -reinert
t := C'first;
loop
do something...
exit when Condition;
t := t + 1;
end loop;
The conditon is just a boolean expression. It can be as simple or as complicated as one desires.
I would like an exit possibility somehow like this:except when Y then skip next -- many more lines saved ;-)
for t of C when f(t), but exit when f(t)
loop
do something....
end loop;
Three lines less - keeping errors down :-)
reinert schrieb am Freitag, 27. Oktober 2023 um 16:53:15 UTC+2:
I would like an exit possibility somehow like this:
for t of C when f(t), but exit when f(t)except when Y then skip next -- many more lines saved ;-)
loop
do something....
end loop;
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 322 |
Nodes: | 16 (2 / 14) |
Uptime: | 195:19:42 |
Calls: | 7,082 |
Files: | 12,500 |
Messages: | 5,505,164 |