An access-control program uses the following finite data definitions:
All combinations of the permitted field values are allowed. Two values are distinct if their forms differ or at least one field differs. There are no other fields or restrictions.
Complete the table with the exact integer number of distinct values permitted by each definition.
Unlock full course notes by signing up
Decide which fields require a case check
A meal-order program uses dictionaries with a kind entry. Its data definition permits Counter(item_count) and Delivered(item_count, distance_km). Every valid value contains a positive integer item count; only Delivered values contain a nonnegative delivery distance. Assuming inputs satisfy this definition, which statements about function structure are true? Select all that apply.
Complete a recursive counting template
A temperature logger represents its readings using the following data definition:
Readings is either Empty or Link(value, next).
value is an integer temperature in degrees Celsius.
Repair a nested-alternative calculation
A shipping program accepts valid parcel dictionaries. A Local parcel contains kind="local" and a positive weight_kg. An International parcel contains kind="international", a positive weight_kg, and a declaration dictionary. That declaration is either Documents, with only kind="documents", or Goods, with kind="goods" and a nonnegative value_dollars.
Local shipping costs 5.00 dollars per kilogram. International shipping costs 12.00 dollars plus 7.00 dollars per kilogram, with an additional 4% of declared value for Goods only. The following function fails for some valid inputs. Which correction makes it implement the stated charges for every permitted form?
Trace calls across nested data definitions
A file browser uses two data definitions:
Item is either File(size) or Folder(contents). File sizes are non-negative integers in bytes, and folder contents are an ItemList.
ItemList is either Empty() or Cons(first, rest), where first is an Item and rest is another ItemList.