aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorFlavian Kaufmann <flavian@flaviankaufmann.ch>2025-05-22 15:16:40 +0200
committerFlavian Kaufmann <flavian@flaviankaufmann.ch>2025-05-22 15:16:40 +0200
commit987a7c553701251d48b11a2243892ecd74ce6c4d (patch)
tree92ba268dc32b33724fbb05b6500af7288dac9617 /examples
parent056adf22dcbeacbbd64623961f2b8825420f90c5 (diff)
downloadimp-987a7c553701251d48b11a2243892ecd74ce6c4d.tar.gz
imp-987a7c553701251d48b11a2243892ecd74ce6c4d.zip
[doc] added documentation in ast and hashmap headers
Diffstat (limited to 'examples')
-rw-r--r--examples/gcd.imp16
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/gcd.imp b/examples/gcd.imp
new file mode 100644
index 0000000..5ab0bbf
--- /dev/null
+++ b/examples/gcd.imp
@@ -0,0 +1,16 @@
+/* computes greatest common divisor (gcd) of a and b */
+procedure gcd(a, b; r) begin
+ if b = 0 then
+ r := a;
+ else
+ q := a;
+ while q >= b do
+ q := q - b;
+ end;
+ gcd(b, q; r);
+ end;
+end;
+
+x := 48;
+y := 18;
+gcd(x, y; result);