My code as generated working through the book by Badrinarayanan Lakshmiraghavan