implementing map using foldr