While answering this question, I came to realize that I was not sure whether Perl\'s map
can be considered a loop or not?
On one hand, it quacks/walks l
It all depends on how you look at it...
On the one hand, Perl's map
can be considered a loop, if only because that's how it's implemented in (current versions of) Perl.
On the other, though, I view it as a functional map
and choose to use it accordingly which, among other things, includes only making the assumption that all elements of the list will be visited, but not making any assumptions about the order in which they will be visited. Aside from the degree of functional purity this brings and giving map
a reason to exist and be used instead of for
, this also leaves me in good shape if some future version of Perl provides a parallelizable implementation of map
. (Not that I have any expectation of that ever happening...)