From d2c4e256c339f85e6e4d78ce323807c2c76888cd Mon Sep 17 00:00:00 2001 From: ntua-el20061 Date: Mon, 24 Feb 2025 22:24:15 +0200 Subject: [PATCH 1/9] new file: dana/programs/gcd.dana --- dana/programs/gcd.dana | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 dana/programs/gcd.dana diff --git a/dana/programs/gcd.dana b/dana/programs/gcd.dana new file mode 100644 index 0000000..ae83809 --- /dev/null +++ b/dana/programs/gcd.dana @@ -0,0 +1,15 @@ +def main + + def gcd is int: a b as int + if b == 0: return: a + else: return: gcd(b, a % b) + + var n1 is int + var n2 is int + var d is int + + n1 := readInteger() + n2 := readInteger() + d := gcd(n1, n2) + writeInteger: d + writeString: "\n" \ No newline at end of file From 5965350aefc17620825617f8830b36353053218b Mon Sep 17 00:00:00 2001 From: ntua-el20061 Date: Mon, 24 Feb 2025 22:27:07 +0200 Subject: [PATCH 2/9] new file: dana/programs/gcd.input new file: dana/programs/gcd.result --- dana/programs/gcd.input | 1 + dana/programs/gcd.result | 1 + 2 files changed, 2 insertions(+) create mode 100644 dana/programs/gcd.input create mode 100644 dana/programs/gcd.result diff --git a/dana/programs/gcd.input b/dana/programs/gcd.input new file mode 100644 index 0000000..6f52257 --- /dev/null +++ b/dana/programs/gcd.input @@ -0,0 +1 @@ +24 18 \ No newline at end of file diff --git a/dana/programs/gcd.result b/dana/programs/gcd.result new file mode 100644 index 0000000..1e8b314 --- /dev/null +++ b/dana/programs/gcd.result @@ -0,0 +1 @@ +6 From 22e0a617d14a4a4bc369f29ece00888e140d072d Mon Sep 17 00:00:00 2001 From: ntua-el20061 Date: Tue, 25 Feb 2025 20:57:44 +0200 Subject: [PATCH 3/9] modified: dana/programs/gcd.dana --- dana/programs/gcd.dana | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/dana/programs/gcd.dana b/dana/programs/gcd.dana index ae83809..53a6282 100644 --- a/dana/programs/gcd.dana +++ b/dana/programs/gcd.dana @@ -1,15 +1,24 @@ def main def gcd is int: a b as int - if b == 0: return: a - else: return: gcd(b, a % b) + if b == 0: return: a + else: + begin + var s is int + s := gcd: b, a % b + return: s + end - var n1 is int - var n2 is int - var d is int + var n1 n2 is int + (* just messing around *) var d is int + writeString: "Give first integer: " n1 := readInteger() + writeString: "\n" + writeString: "Give second integer: " n2 := readInteger() - d := gcd(n1, n2) + writeString: "\n" + d := gcd(n1, n2) + writeString: "The gcd is: " writeInteger: d writeString: "\n" \ No newline at end of file From 20c94c6202931bc2f7e8ab9422fbffae090e2d8c Mon Sep 17 00:00:00 2001 From: ntua-el20061 Date: Tue, 25 Feb 2025 21:11:43 +0200 Subject: [PATCH 4/9] modified: dana/programs/gcd.dana modified: dana/programs/gcd.result --- dana/programs/gcd.dana | 9 +++++---- dana/programs/gcd.result | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dana/programs/gcd.dana b/dana/programs/gcd.dana index 53a6282..08b4b89 100644 --- a/dana/programs/gcd.dana +++ b/dana/programs/gcd.dana @@ -12,12 +12,13 @@ def main var n1 n2 is int (* just messing around *) var d is int - writeString: "Give first integer: " n1 := readInteger() - writeString: "\n" - writeString: "Give second integer: " n2 := readInteger() - writeString: "\n" + + # Making sure numbers are non-negative + + if n1 < 0: n1 := -n1 + if not n2 >= 0: n2 := -n2 d := gcd(n1, n2) writeString: "The gcd is: " writeInteger: d diff --git a/dana/programs/gcd.result b/dana/programs/gcd.result index 1e8b314..1493b16 100644 --- a/dana/programs/gcd.result +++ b/dana/programs/gcd.result @@ -1 +1 @@ -6 +The gcd is 6 \ No newline at end of file From f9a5d22bf5777a9a429d40daad67b5e01ce8ab5c Mon Sep 17 00:00:00 2001 From: ntua-el20061 Date: Tue, 25 Feb 2025 23:44:58 +0200 Subject: [PATCH 5/9] modified: dana/programs/gcd.dana --- dana/programs/gcd.dana | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dana/programs/gcd.dana b/dana/programs/gcd.dana index 08b4b89..c231e6a 100644 --- a/dana/programs/gcd.dana +++ b/dana/programs/gcd.dana @@ -12,6 +12,7 @@ def main var n1 n2 is int (* just messing around *) var d is int + writeString: "Give me two positive integers: \n" n1 := readInteger() n2 := readInteger() @@ -20,6 +21,6 @@ def main if n1 < 0: n1 := -n1 if not n2 >= 0: n2 := -n2 d := gcd(n1, n2) - writeString: "The gcd is: " + writeString: "\nTheir GCD is: " writeInteger: d writeString: "\n" \ No newline at end of file From ac7bf53c47c4e65d6810c729adf973326404b97e Mon Sep 17 00:00:00 2001 From: ntua-el20061 Date: Tue, 25 Feb 2025 23:47:38 +0200 Subject: [PATCH 6/9] modified: dana/programs/gcd.input modified: dana/programs/gcd.result --- dana/programs/gcd.input | 2 +- dana/programs/gcd.result | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dana/programs/gcd.input b/dana/programs/gcd.input index 6f52257..9318f84 100644 --- a/dana/programs/gcd.input +++ b/dana/programs/gcd.input @@ -1 +1 @@ -24 18 \ No newline at end of file +../../alan/programs/gcd.input \ No newline at end of file diff --git a/dana/programs/gcd.result b/dana/programs/gcd.result index 1493b16..a163c39 100644 --- a/dana/programs/gcd.result +++ b/dana/programs/gcd.result @@ -1 +1 @@ -The gcd is 6 \ No newline at end of file +../../alan/programs/gcd.result \ No newline at end of file From 673945c8d116e5a04ff27df178b52b4e5bc5bb58 Mon Sep 17 00:00:00 2001 From: Kostis Sagonas Date: Tue, 25 Feb 2025 23:43:49 +0100 Subject: [PATCH 7/9] Add a new line at EOF --- dana/programs/gcd.dana | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dana/programs/gcd.dana b/dana/programs/gcd.dana index c231e6a..c7cc889 100644 --- a/dana/programs/gcd.dana +++ b/dana/programs/gcd.dana @@ -23,4 +23,4 @@ def main d := gcd(n1, n2) writeString: "\nTheir GCD is: " writeInteger: d - writeString: "\n" \ No newline at end of file + writeString: "\n" From e6d13ff79a79ce7a2e6b0a1fe738e8225069a43d Mon Sep 17 00:00:00 2001 From: Kostis Sagonas Date: Tue, 25 Feb 2025 23:45:05 +0100 Subject: [PATCH 8/9] Delete dana/programs/gcd.input We will add a symbolic link instead. --- dana/programs/gcd.input | 1 - 1 file changed, 1 deletion(-) delete mode 100644 dana/programs/gcd.input diff --git a/dana/programs/gcd.input b/dana/programs/gcd.input deleted file mode 100644 index 9318f84..0000000 --- a/dana/programs/gcd.input +++ /dev/null @@ -1 +0,0 @@ -../../alan/programs/gcd.input \ No newline at end of file From 2ee80309a703b03879bc6b2a6b10bd3a5c6ba9d5 Mon Sep 17 00:00:00 2001 From: Kostis Sagonas Date: Tue, 25 Feb 2025 23:45:32 +0100 Subject: [PATCH 9/9] Delete dana/programs/gcd.result We will add a symbolic link instead. --- dana/programs/gcd.result | 1 - 1 file changed, 1 deletion(-) delete mode 100644 dana/programs/gcd.result diff --git a/dana/programs/gcd.result b/dana/programs/gcd.result deleted file mode 100644 index a163c39..0000000 --- a/dana/programs/gcd.result +++ /dev/null @@ -1 +0,0 @@ -../../alan/programs/gcd.result \ No newline at end of file