Rewrite tr using foldl

Not convinced this helps at all...