mul div mod add sub in Nim

This commit is contained in:
sforman 2023-08-12 07:54:33 -07:00
parent f45c739fad
commit 99f01bec1f
1 changed files with 5 additions and 5 deletions

View File

@ -483,27 +483,27 @@ it looks up in the dictionary.
proc joy_eval(sym: string, stack: JoyListType, expression: JoyListType, dictionary: JoyMapType): (JoyListType, JoyListType, JoyMapType) =
case sym
of "+":
of "+", "add":
let (a, s0) = pop_int(stack)
let (b, s1) = pop_int(s0)
return (push_int(a + b, s1), expression, dictionary)
of "-":
of "-", "sub":
let (a, s0) = pop_int(stack)
let (b, s1) = pop_int(s0)
return (push_int(b - a, s1), expression, dictionary)
of "*":
of "*", "mul":
let (a, s0) = pop_int(stack)
let (b, s1) = pop_int(s0)
return (push_int(a * b, s1), expression, dictionary)
of "/":
of "/", "div":
let (a, s0) = pop_int(stack)
let (b, s1) = pop_int(s0)
return (push_int(b div a, s1), expression, dictionary)
of "%":
of "%", "mod":
let (a, s0) = pop_int(stack)
let (b, s1) = pop_int(s0)
return (push_int(b mod a, s1), expression, dictionary)