basic algorithms and patterns implemented in scala