Examples from programming in scala 2nd edition