exercises ex3.7 to ex3.11; add my own notes on useful scala code snippets