From 3ceb2ecab5d2f8d091df271c959a89437175af3f Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 14 Jul 2023 23:05:29 +0100 Subject: Add example program for ifs --- examples/if/shed.toml | 9 +++++++++ examples/if/src/Counting.shed | 15 +++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 examples/if/shed.toml create mode 100644 examples/if/src/Counting.shed (limited to 'examples') diff --git a/examples/if/shed.toml b/examples/if/shed.toml new file mode 100644 index 00000000..bbbffff5 --- /dev/null +++ b/examples/if/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/if/src/Counting.shed b/examples/if/src/Counting.shed new file mode 100644 index 00000000..060482b5 --- /dev/null +++ b/examples/if/src/Counting.shed @@ -0,0 +1,15 @@ +fun message(count: Int) -> String { + if (count == 1) { + "one\n" + } else if (count == 2) { + "two\n" + } else { + "many\n" + } +} + +fun main() ! Io -> Unit { + print!(message(1)); + print!(message(2)); + print!(message(3)); +} -- cgit v1.2.3