Robert Klemme wrote:
begin
a,b = b,a % b
end while b != 0
Not trying to “golf”, but is the begin/end necessary here?
Robert Klemme wrote:
begin
a,b = b,a % b
end while b != 0
Not trying to “golf”, but is the begin/end necessary here?
“Michael Campbell” michael_s_campbell@yahoo.com schrieb im Newsbeitrag
news:20031211160102.24728.qmail@web12408.mail.yahoo.com…
Robert Klemme wrote:
begin
a,b = b,a % b
end while b != 0Not trying to “golf”, but is the begin/end necessary here?
No. It’s a relict from the evoltion process. But you’re right
a,b = b,a % b while b != 0
looks much better. :-))
Thanks
robert
“Michael Campbell” michael_s_campbell@yahoo.com schrieb im Newsbeitrag
news:20031211160102.24728.qmail@web12408.mail.yahoo.com…Robert Klemme wrote:
begin
a,b = b,a % b
end while b != 0Not trying to “golf”, but is the begin/end necessary here?
Actually, the begin/end make the above incorrect. It will break
down for b = 0.
No. It’s a relict from the evoltion process. But you’re right
a,b = b,a % b while b != 0
looks much better. :-))
It may look better, but try:
fail while false
vs.
begin fail end while false
The first case will not raise an exception, because the while condition
is tested at the beginning of the loop, while the second case tests
the condition at the end of the loop and raises an exception.
Therefore, there is a clear difference in semantics. To make it
unambiguous, just use:
while b != 0 do a, b = b, a % b end
which is probably the clearest way to express what you need.
Reimer Behrends
Robert Klemme (bob.news@gmx.net) wrote: