Implement map() with reduce()