eval: fixed first state forgetfulness issue

This commit is contained in:
2017-05-22 18:56:27 -04:00
parent 0fb92f60da
commit 545d2896a1

View File

@@ -135,7 +135,12 @@ funCall state (BFun name args body) provided =
callWith state (a:args) (p:provided) =
let (evald, nstate) = eval state p
in callWith (M.insert a evald nstate) args provided
-- TODO: fix state forgetfulness
funCall state (BNative body) provided =
let args = map (fst . (eval state)) provided
let (args, nstate) = callWith state provided
in (body args, state)
-- TODO: make tail recursive with accumulator
where callWith state [] = (state, [])
callWith state (x:xs) =
let (evald, nstate) = eval state x
(retstate, l) = callWith nstate xs
in (retstate, evald:l)