aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorFlavian Kaufmann <flavian@flaviankaufmann.ch>2025-05-22 13:42:33 +0200
committerFlavian Kaufmann <flavian@flaviankaufmann.ch>2025-05-22 13:42:33 +0200
commita80f818de34a631b4b1c9c9e866c6f43de07d816 (patch)
tree4a157c098cc44e7ee709775ab28a5856f3d2c259 /examples
parent6ef8829451871b534572d47312ae255dee088588 (diff)
downloadimp-a80f818de34a631b4b1c9c9e866c6f43de07d816.tar.gz
imp-a80f818de34a631b4b1c9c9e866c6f43de07d816.zip
support for comments
Diffstat (limited to 'examples')
-rw-r--r--examples/example.imp12
-rw-r--r--examples/factorial.imp1
2 files changed, 8 insertions, 5 deletions
diff --git a/examples/example.imp b/examples/example.imp
index de76b27..c60caa3 100644
--- a/examples/example.imp
+++ b/examples/example.imp
@@ -1,11 +1,13 @@
-f1 := 0;
-f2 := 1;
+/* computes the n-th fibonacci number */
+
+fib := 0;
+fibnext := 1;
n := 5;
while n # 0 do
- var tmp := f2 in
- f2 := f1 + f2;
- f1 := tmp;
+ var tmp := fibnext in
+ fibnext := fib + fibnext;
+ fib := tmp;
end;
n := n - 1;
end; \ No newline at end of file
diff --git a/examples/factorial.imp b/examples/factorial.imp
index 0ab74cd..4cb47ed 100644
--- a/examples/factorial.imp
+++ b/examples/factorial.imp
@@ -1,3 +1,4 @@
+/* computes n!, result is stored in r. */
procedure factorial(n;r) begin
if n <= 0 then
r := 1;