Section 4.3 Flashcards

1
Q

True or false: Constant pattern matching in Miranda is strict.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or false: Sum pattern matching in Miranda is strict.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

True or false: Product pattern matching in Miranda is strict.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

True or false: Lazy product matching is less efficient than strict product matching.

A

True. Applying lazy product matching can require more reductions than strict pattern matching.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why do the semantic equations for pattern matching not include mismatched arguments (e.g a non-product argument applied to a lambda abstraction with a product pattern)?

A

The evaluation function is defined as an ordinary mathematical function, and such definitions are given only on the function’s domain.

Operationally, the type-checker ensures that functions are never applied to values outside of their domain.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What properties of a case expression make efficient implementation possible?

A

Exhaustiveness and the restriction to simple patterns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Why is exhaustiveness required?

A

The patterns must be exhaustive so that the unconditional jump on the constructor always succeeds.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Why is the simple pattern restriction required?

A

If the one of the patterns is nested, one can no longer jump on the outermost constructor alone.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly