ex 1.28 wip
translate sicp-ex 1.28 to scala