Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
pp:l04xx [2020/03/20 21:33]
pdmatei
pp:l04xx [2020/04/07 15:11] (current)
pdmatei
Line 1: Line 1:
-======= Programming with ADTs =======+======= ​6. Programming with ADTs =======
  
 1. A **dictionary** is a collection of key-value pairs, which we can represent in Haskell as a list of pairs ''​(String,​Integer)''​ where ''​String''​ is the key type and ''​Integer''​ is the value type: 1. A **dictionary** is a collection of key-value pairs, which we can represent in Haskell as a list of pairs ''​(String,​Integer)''​ where ''​String''​ is the key type and ''​Integer''​ is the value type:
Line 25: Line 25:
 </​code>​ </​code>​
  
-4. Implement a function which takes a dictionary of program variables, a program expression ''​PExpr'',​ and evaluates it. For instance: ''​eval_pexpr [("​x",​2),​("​y",​1)] ((Var "​x"​) :+: (Var "​y"​))''​ returns 3.+4. Implement a function which takes a dictionary of program variables, a program expression ''​PExpr'',​ and evaluates it. For instance: ''​eval_pexpr [("​x",​2),​("​y",​1)] ( (Var "​x"​) :+: (Var "​y"​) )''​ returns 3.
 <code haskell> <code haskell>
 eval_pexpr :: Dict -> PExpr -> Integer eval_pexpr :: Dict -> PExpr -> Integer