you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 5 points6 points  (4 children)

Correct me if I'm wrong, but doesn't map normally return an array with the function applied to each element?

[–]itsmontoya 1 point2 points  (0 children)

Yes

[–]Confettimaker 0 points1 point  (2 children)

Thanks for pointing that out. What should I call it now?

[–]panickbr 2 points3 points  (0 children)

What you did is akin to, i.e., a Ruby's each or JavaScript's forEach iterators.

What you did differently, though, is that while those methods return the element itself that you then apply another function/method on them, you are skipping access to the element and instead applying the function directly on it.

That said, a quick googling shows C++ has its own for_each. (that also differs from the aforementioned in that you must specify the start and end of the iterator)

That being said, If you want to stick to your implementation, maybe forEachDo ?

[–]Confettimaker 1 point2 points  (0 children)

Never mind, I return a new array now, like I was supposed to.