This is the 'homework' from video 4 (functions).
Define && using double dispatch. (This is on our hypothetical Bool class).
- Consider a function safetail that behaves in the same way as tail, except that safetail maps the empty list to the empty list, whereas tail gives an error in this case. Define safetail using:
- a conditional expression
- guarded equations
- pattern matching
- Give three possible definitions for the logical or operator (||) using pattern matching.
- Redefine the following version of (&&) using conditionals rather than patterns:
- Do the same for the following version:
Edited by R. Jensen on Dec 14, 2011 11:28 PM