From fbdf2e42f2013ecbbe9d35f91b4541fcd3d80d51 Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Sun, 6 Nov 2022 06:18:07 +0100 Subject: [PATCH] Implement remaining command_... functions for control structures --- lambdaV.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lambdaV.py b/lambdaV.py index ff56d3b..ce55c1a 100644 --- a/lambdaV.py +++ b/lambdaV.py @@ -173,12 +173,28 @@ def command_take(): return "" def command_repeat(number, parsed_code): + for i in range(number): + result = run_code(parsed_code) + if not result=="": + return result return "" def command_while(parsed_condition, parsed_code): + while parsed_condition[0](parsed_condition[1]): + result = run_code(parsed_code) + if not result=="": + return result return "" def command_if(parsed_condition, parsed_then_code, parsed_else_code): + if parsed_condition[0](parsed_condition[1]): + result = run_code(parsed_then_code) + if not result=="": + return result + elif not parsed_else_code==None: + result = run_code(parsed_else_code) + if not result=="": + return result return ""