improved implementations of reverse and append() using the fold functions