Is "map" a loop?
Posted
by DVK
on Stack Overflow
See other posts from Stack Overflow
or by DVK
Published on 2010-06-11T03:01:09Z
Indexed on
2010/06/11
3:02 UTC
Read the original article
Hit count: 514
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 like a loop (does O(n) work, can be easily re-written by an equivalent loop, and sort of fits the common definition = "a sequence of instructions that is continually repeated").
On the other hand, map
is not usually listed among Perl's control structures, of which loops are a subset of. E.g. http://en.wikipedia.org/wiki/Perl_control_structures#Loops
So, what i'm looking for is a formal reason to be convinced of one side vs. the other. So far, the former (it is a loop) sounds a lot more convincing to me, but I'm bothered by the fact that I never saw "map" mentioned in a list of Perl loops.
© Stack Overflow or respective owner