Skip to content

Commit 3033a06

Browse files
committed
Update comments in sum.alk
1 parent 959ab3f commit 3033a06

File tree

1 file changed

+17
-3
lines changed
  • examples/used-in-papers/sacs2024

1 file changed

+17
-3
lines changed

examples/used-in-papers/sacs2024/sum.alk

+17-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ print(result) // Output: 66
2929

3030
// First attempt
3131

32+
/*
3233
computeSum(n, m) {
3334
lst = <2..n>; // Initialize the lst with numbers 2 to n
3435
for (round = 1; round <= m; ++round) {
@@ -44,9 +45,16 @@ computeSum(n, m) {
4445
sum = sum + lst.at(i); // Compute the sum of all numbers in the lst
4546
return sum;
4647
}
48+
// Example usage
49+
n = 5;
50+
m = 3;
51+
result = computeSum(n, m);
52+
print(result); // Expected output: 66
53+
//Error at [37:16]: The position in the list is out of bounds.
54+
*/
4755

4856
// Fixed version
49-
/*
57+
5058
computeSum(n, m){
5159
lst = <2..n>; // Initialize the lst with numbers 2 to n
5260
for (round = 1; round <= m; ++round) {
@@ -62,9 +70,15 @@ computeSum(n, m){
6270
sum = sum + lst.at(i-1); // Compute the sum of all numbers in the lst
6371
return sum;
6472
}
65-
*/
73+
6674
// Example usage
6775
n = 5;
6876
m = 3;
6977
result = computeSum(n, m);
70-
print(result); // Output: 66
78+
print(result); // Expected output: 66
79+
/*
80+
26
81+
result |-> 26
82+
m |-> 3
83+
n |-> 5
84+
*/

0 commit comments

Comments
 (0)