Add function reverse
Merge pull request #587 from sigurdteigen/master

reverse function