From 0b43f1e9685ddcee4477e7d765dbc7a64f31d99a Mon Sep 17 00:00:00 2001 From: a dinosaur Date: Mon, 11 Sep 2023 20:50:41 +1000 Subject: [PATCH] examples: simplify row builder using arrays --- examples/boolean.pork | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/examples/boolean.pork b/examples/boolean.pork index e56a555..6f9b9e4 100644 --- a/examples/boolean.pork +++ b/examples/boolean.pork @@ -1,14 +1,11 @@ func buildRow(str, a, b, c, d) { - let checkSeparator = "| " - print("|", str, checkSeparator) - if a { print("✅") } else { print("🚫") } - print(checkSeparator) - if b { print("✅") } else { print("🚫") } - print(checkSeparator) - if c { print("✅") } else { print("🚫") } - print(checkSeparator) - if d { print("✅") } else { print("🚫") } - println("|") + let checkSeparator = " " + print("|", str, "| ") + for i in [a, b, c, d] { + print(checkSeparator) + if a { print("✅|") } else { print("🚫|") } + } + println() } export func main() { @@ -29,5 +26,5 @@ export func main() { buildRow("!a || b", (not false) or false, (not true) or false, (not false) or true, (not true) or true) buildRow(" a || !b", false or (not false), true or (not false), false or (not true), true or (not true)) buildRow("!a || !b", (not false) or (not false), (not true) or (not false), (not false) or (not true), (not true) or (not true)) - println("|-----------------------------------------------------|") + println("|------------------------------------------------------|") }