News for hackers. Stuff that matters.
Re:GCD and the magic of subtraction by augustk on Tuesday August 25, 2020 @10:46AM (#24271855)
A generalized version of the while loop was suggested by Edsger Dijkstra. This loop has more than one guard and terminates when all guards evaluate to false. With this construct the greatest common divisor can be calculated quite succinctly as

  WHILE a < b DO
     b := b - a
  ELSIF a > b DO
     a := a - b
  END
The Oberon programming language by Niklaus Wirth supports the Dijkstra while loop.

https://miasap.se/obnc/oberon-report.html#sec9.6

Re:GCD and the magic of subtraction by whatshisface on Tuesday August 25, 2020 @10:57AM (#24271963)
Wouldn't that be `else: break` in every other language?
Re:GCD and the magic of subtraction by nils-m-holm on Tuesday August 25, 2020 @11:14AM (#24272176)
In most other languages it would be something like

    while true do
        if condition 1 do
            statements 1
        done
        else if condition 2 do
            statements 2
        done
        else do
            break
        done
    done
Re:GCD and the magic of subtraction by augustk on Tuesday August 25, 2020 @01:13PM (#24273568)
Oberon, however, is a purely structured language and has no goto-like statements like "break".