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 state function of type string -> int. makes easy value of variable; value of "a" in state, call state "a". whenever assign variable, want update program state. implement following function:

extend :: state -> string -> int -> state

hint: 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

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -