ex4.2 - implement variance with flatMap
minor revisions to ch3 solns after comparing with authors' solns