Is “map” a loop?

map is a higher level concept than loops, borrowed from functional programming. It doesn’t say “call this function on each of these items, one by one, from beginning to end,” it says “call this function on all of these items.” It might be implemented as a loop, but that’s not the point — it also might be implemented asynchronously — it would still be map.

Additionally, it’s not really a control structure in itself — what if every perl function that used a loop in its implementation were listed under “loops?” Just because something is implemented using a loop, doesn’t mean it should be considered its own type of loop.

Leave a Comment