in reply to Re^2: Applying regex to array
in thread Applying regex to array
Personally, I still think it's an abuse of map when foreach can be used to do the same thing. But YMMV :)
I used to think that, but it's such a common thing to be suggested that I think it's worth asking why. Actually, I also think I have an answer. This paper on natural programming languages has some interesting things to say about how people naturally think about solving problems:
Aggregate operators (acting on a set of objects all at once) were used much more often than iterating through the set and acting on the objects individually. For example, "Move everyone below the 5th place down by one."
While one can argue the meaning of this, this and the rest of the paper suggested to me that programming in a way that matches how people (not necessarily just programmers) think is more likely to produce good code. The paper is an interesting read.
Cheers,
Ovid
New address of my CGI Course.
|
|---|