From 4f2cf10ed2459a97cddc567a0d454e3857bd54d8 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 27 Aug 2023 22:45:55 +0100 Subject: Support loops in WASM Patio code generator --- examples/while/shed.toml | 9 +++++++++ examples/while/src/Counting.shed | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 examples/while/shed.toml create mode 100644 examples/while/src/Counting.shed (limited to 'examples') diff --git a/examples/while/shed.toml b/examples/while/shed.toml new file mode 100644 index 00000000..bbbffff5 --- /dev/null +++ b/examples/while/shed.toml @@ -0,0 +1,9 @@ +[shed] +main = "Counting" + +[[shed.bins]] +name = "counting" + +[[shed.examples]] +bin = "counting" +expected-output = "one\ntwo\nmany" diff --git a/examples/while/src/Counting.shed b/examples/while/src/Counting.shed new file mode 100644 index 00000000..8275fa0c --- /dev/null +++ b/examples/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" + } +} + +fun main() ! Io -> Unit { + var count = 1; + + while (count != 4) { + print!(message(count)); + assign count := count + 1; + } +} -- cgit v1.2.3