![]() |
.. (לתיקייה המכילה) | |
Can we define multiple datatypes in Q1 or in Q2?
| No. The idea is to solve the Qs with a single datatype |
Can we use exceptions in this HW
| No. |
Can you give more examples for Q3?
| Yes. They have been published separately. You can find them under HW5 in the Assignments page. |
I am getting the character # in some of ML's replys to my declarations, and the declared values seem to be too short. Is this OK?
|
Yes it is (generally). The # char is ML saying `etc etc'. You can make ML type out fully the declared value by using this command at the beginning of your session: - Compiler.Control.Print.printDepth := 1000; |
Q1: We don't understand the use of square brackets. Can you explain?
|
The usage of square brackets in ML is `syntactic sugar'. It is a shortcut for the long, but correct, syntax - in which constructors are used. So the list [1,2,3] is really just a shortcut for ::(1,(::(2,(::(3,nil))))). This is a regular list, and the constructors are :: and nil. The idea is for you to define a datatype (and its constructors) such that nested lists are values of that type. |
Q1: We don't understand the use of square brackets. Can you explain? (continued)
| The `example' we gave is fiction. You cannot write [[1],2,[[3,4]]] etc., and we don't expect that with the new datatype it will become possible. Instead, a list like that will look something like Const1(Const2(... or whatever, a complex expression involving constructors. The point of the example is to give you an understanding of what do the values of the new type mean. They mean nested lists. |
Q1 HINT!
| Think how you would define list as a datatype, but don't use lists in your definition of nlist |
Compiler.Control.Print.printDepth := 1000; is not working!
|
Try the older version of Ml, that can be downloaded from last semester's website. There are also rumors that Control.Print.printDepth := 1000 (without Compiler) works in the new version. |
We got map_file = fn : 'a element -> ('a element -> 'b element) -> 'b element
and
map_dir = fn : 'a directory -> ('a element -> 'b element) -> 'b directory
is that OK?
| Yes. |

