Question 1 @ 2024-10-01 18:35
Which of the following points is true about Typed Racket?
- Any type can be a union of several types
- Only function input types can be unions of several types
- A type-system is kind of like a simple theorem prover for code
- A type-system must be simple to avoid heavy runtime penalty
-
The
Any
type is at the top of the type hierarchy, and it represents knowing the most about a value.
Question 2 @ 2024-10-01 18:39
Consider the following WAE expression:
{+ x
{with {y x} y}}}
After one substitution step (i.e., what eval
does in one step only),
we get:
{with {y ?B?} y}}
What should we see in the two ?A?
and ?B?
places respectively?
-
x
,x
-
x
,5
-
5
,x
-
5
,5
Question 3 @ 2024-10-01 18:42
In homework #3, we’ve seen tests like:
Is there any problem with this test?
-
No.
-
Impossible to tell from just an example, since it depends on how the test is implemented.
-
There’s a minor problem: it would be better to use
(list 3 -3)
in the output. -
There’s a problem of testing a particular order of the results, which means that it’s over-testing an implementation detail.
-
There’s a possible problem when we consider that Racket should deal with floating point numbers, so using
'(3.0 -3.0)
is better.
Question 4 @ 2024-10-01 18:45
Given that the answer to the last question
is that this tests a particular order, what would be the best approach to fix it?
(Choose the best answer.)
- Switch the implementation to use sets instead of lists.
-
Sort the results of
sqrt
. -
Sort the results of
eval
. -
Sort the results of
run
in the test. - Implement a new kind of a test that uses a two nested loops to compare each value on both sides to implement set equality.