diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-08-27 22:45:55 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-08-27 22:45:55 +0100 |
| commit | 4f2cf10ed2459a97cddc567a0d454e3857bd54d8 (patch) | |
| tree | 811d506e270dd596091a9c32fd45c80048b247ad /examples | |
| parent | 03ade518f7c821cd0b44dfebf5872bd49b77298c (diff) | |
Support loops in WASM Patio code generator
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/while/shed.toml | 9 | ||||
| -rw-r--r-- | examples/while/src/Counting.shed | 18 |
2 files changed, 27 insertions, 0 deletions
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; + } +} |
