From 6f23c311ce87833748e7a5ad07321b0b9d45cb21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juli=C3=A1n=20Gonz=C3=A1lez=20Calder=C3=B3n?= Date: Thu, 18 Apr 2024 18:06:02 -0300 Subject: [PATCH] Improve example by only keeping minimal syntax --- examples/for_while.con | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/examples/for_while.con b/examples/for_while.con index 80f9d3e..2f3612d 100644 --- a/examples/for_while.con +++ b/examples/for_while.con @@ -1,18 +1,12 @@ mod Example { fn main() -> i64 { - return sum_to(4); + return sum_to_twice(4); } - fn sum_to(limit: i64) -> i64 { + fn sum_to_twice(limit: i64) -> i64 { let mut result: i64 = 0; let n: i64 = 1; - for (; n <= limit ;) { - result = result + n; - n = n + 1; - } - - n = 1; for (n <= limit) { result = result + n; n = n + 1;