This is the third (?) task of the mlpractice package.
You should fill in the gaps in the given function templates.