homework for Functional Programming