Implementing an interpreter in Haskell exercise CIS194 -
i'm lerning haskell material can found here. i'm begining homework 3 in objective write interpreter simple language i'm stuck in first exercise:
before can start evaluating expressions , statements need way store , state of variable. define
statefunction of typestring -> int. makes easy value of variable; value of"a"instate, callstate "a". whenever assign variable, want update programstate. implement following function:
extend :: state -> string -> int -> statehint: can use input state black box variables other 1 assigning.
example:
let st’ = extend st "a" 5
in st’ "a" == 5
i don't i'm supposed doing here. in hint i'm not sure "black box" means. in example st' state, i'm not sure in st' "a" == 5 doing.
if clarify both hint , example me think able solve exercise.
"black box" means can ignore how it's implemented , use it. let foo = bar in baz binds new variable foo expression bar, results in baz (which may mention foo); presumably here point given haskell expression should evaluate true -- is, test case implementation.
Comments
Post a Comment