FP101x Introduction to Functional Programming, homework 4