![]() |
.. (לתיקייה המכילה) | |
ML compiler prints out short responses containing # character. Why is that? | |
Please read ML folder under FAQ section. |
Q1 c: how exactly does the string suppose to look like? | |
The string should translate: Conj(p,q) => (_p_&_q_) Disj(p,q) => (_p_|_q_) Neg(p) => (_~_p_) Atom(p) => p where instead of underscore you should put space. |
Q1 b: What is an illegal mapping? | |
A legal mapping is a mapping that has a boolean value to every atom exactly once (no matter in what order). So: - if an atom doesn't have a true/false value the mapping is illegal. - if an atom have a true/false value several times the mapping is illegal |
Q1 d: Does the function nnf return a string or a prop value? | |
prop value |
Q2: can we use the 'a list type solving this question? | |
You may not. You need to define a datatype that represents a list containing values with two type as described. |
Q1 b: can we implement an auxiliary function? | |
Yes you can. |
Q3: is the tree NIL a legal tree? | |
No it is not. Every tree representing a number must have at least one digit. |
Q3 e; When receiving an s_expr can we assume it is legal? | |
No you may not. When the input is illegal return NIL. |
Q2: I managed to define the datatype as required but i can still use both constructors (when inserting values of the second type). Is that OK? | |
That is OK, as long as you must continue inserting values of the second type and can't insert values of any other type. |
Why is emptyCell defined for? | |
emptyCell is the value that should be returned when get functions receives an index of an empty cell. emptyCell is the value that should be returned when get receives an illegal index. |
Q4: Can we assume that the indexes are between 0 to array_size-1? | |
No you may not. In case of an illegal index: Get- return emptyCell as specified. Set- return the received sparseArray as is (without any change). |
Q3: Suggested solution for Q3 c: | |
Implement to following functions: isLegalBinNumber: To check if the input is a legal binary number reverseNum: Reverses the number 1010 => 0101 sumDigits: Sums two digits with carry. Receives two digits and carry and returns a digit and a carry. Now sum two numbers the following way: 1, check that both numbers are legal. 2, reverse them. 3, sum them digit by digit (don't forget the carry) from root to bottom. 4, reverse the result. This is one way of solving this problem. You can solve it how ever you like as long as you don't translate the numbers to other representations. |
Q4: complexity | |
Define: Array length: The length of the array represented- 9 in the example Not empty cells (Value elements): 3 in the example Array elements (Gap+Value elements): 6 in the example Your solution should be linear to number of array elements and not array length. |
Q3 f g: can we assume that the numbers have the same number of digits? | |
No you can not. |
Q1 b: Can we assume that the mapping is legal? | |
Yes. In order to make it simpler and avoid the need of checking many different mapping problems you may assume that the mapping is legal. Assume that: - Each atom in the formula has exactly one value. - The mapping doesn't include atoms that are not in the logic formula. If you already checked and returned false for illegal mapping as defined before (in the FAQ) that's fine, you don't need to change your implementation. |
Do we need to include types definitions in ex4.sml file? | |
You must include all definitions so that your implementation will run as is. |
Q3: Can we use lists in our solution? | |
You are not suppose to change the number representation therefore use of lists as a mean to save digits is not allowed. |
Can we submit code with Warning: match nonexhaustive? | |
You can. Make sure it will not throw exception for any input. |
Q4 c: Do we need to merge two Value elements? | |
No you do not. |
Q4 b c: What should I do when set receive a "" string? | |
"" is a legitimate string as any other. You create a Value with "" in it. You do not remove it in the compress operation. |