> map ... iterates the entire list and you can't break out of it. > I think it's only a viable > solution in the limited case of a for loop that doesn't have a stopping case
Right, 'map' per se is for when you DO want to do it all. The map {statement} @List ; naturally replaces statement for @List ; not the 'for ($i=0;$i;$i++) {...} ' nor 'while/last' loops nor even for my $x (@List){ ... last ...} ) > As for recursion, I don't think one can easily replace a recursive solution > with map. In functional programming communities, map is initially implemented as, is defined as if built as, and replaces, the classic recursion. Map is a SWIM DRY replacement for recursion in that world view. > Replacing recursion with iteration requires a base > condition (and, possibly, a stack) Recursion requires those, but many uses do not require them. You are correct that map{}grep{}@List is the functional/applicative filter solution. > and map doesn't handle stopping conditions. True. Which simplifies the code template. Why pay for it when you don't need it. > One could work around it, I suppose, but not cheaply and the code would almost > certainly be tasteless. The functional form that shortcuts is really, really ugly :-) use List::Util qw(first); ... $foo = first { $_ >= $minimum } @list ; Bill @ $dayJob // not speaking for $Firm _______________________________________________ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm