aboutsummaryrefslogtreecommitdiff
path: root/examples/12-while/src
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2025-02-02 20:13:05 +0000
committerMichael Williamson <mike@zwobble.org>2025-02-02 20:13:20 +0000
commit89394d0fab076765b637b0fe643d8f8950639817 (patch)
tree6852b4f81fd7f7812bb208df52b4e0cc8b1bcbdf /examples/12-while/src
parent67f010c93b11744b1f2f1c9403fd1e8d2b888acb (diff)
Add int arithmetic example
Diffstat (limited to 'examples/12-while/src')
-rw-r--r--examples/12-while/src/Counting.shed18
1 files changed, 18 insertions, 0 deletions
diff --git a/examples/12-while/src/Counting.shed b/examples/12-while/src/Counting.shed
new file mode 100644
index 00000000..aa95f536
--- /dev/null
+++ b/examples/12-while/src/Counting.shed
@@ -0,0 +1,18 @@
+fun message(count: Int) -> String {
+ if (count == 1) {
+ "one\n"
+ } else if (count == 2) {
+ "two\n"
+ } else {
+ "many\n"
+ }
+}
+
+pub fun main() ! Io -> Unit {
+ var count = 1;
+
+ while (count != 4) {
+ print!(message(count));
+ assign count = count + 1;
+ }
+}