Now when a var is evaluated, the new evaluation replaces the old

This commit is contained in:
Ivy 2021-01-30 00:55:05 +01:00
parent 2a351374a7
commit c15a736236
2 changed files with 8 additions and 7 deletions

View File

@ -15,8 +15,9 @@ base = M.fromList [
eval :: Env -> Expr -> (Env, Expr)
eval env (IntE x) = (env, IntE x)
eval env (VarE v) = eval env $ env M.! v
eval env (SetE v expr) = (M.insert v expr env, expr)
eval env (VarE v) = (M.insert v nExpr nEnv, nExpr)
where (nEnv, nExpr) = eval env $ env M.! v
eval env (SetE v expr) = (M.insert v expr env, NilE)
eval env NilE = (env, NilE)
--apply :: Proc -> Args -> Expr

View File

@ -4,9 +4,9 @@ data Expr = IntE Integer
| VarE String
| ProcedureE String [Expr]
| SetE String Expr
| NilE
| NilE deriving (Show)
instance Show Expr where
show (IntE x) = show x
show (VarE x) = x ++ " ; var"
show NilE = "nil"
-- instance Show Expr where
-- show (IntE x) = show x
-- show (VarE x) = x ++ " ; var"
-- show NilE = "nil"