Added an implementation of the scanl and scanr functions