exercise of spj's ImplementingFunctionalLanguages