fpinscala: ch 6
99 scala problems