Implement remaining command_... functions for control structures
parent
f9f454625b
commit
fbdf2e42f2
16
lambdaV.py
16
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 ""
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue