On 2/26/06, Eric Wilhelm <[EMAIL PROTECTED]> wrote:
Just FYI, it looks a bit different than what the reform() function in Array::Reform does -
http://search.cpan.org/~kilinrax/Array-Reform-1.04/Reform.pm
the author of that module is not very responsive to bug reports, so maybe we could add in that reform() functionality and name this something else (no idea what)
# from James E Keenan
# on Sunday 26 February 2006 05:03 pm:
>I don't really understand reform() -- particularly: what
>goes inside the code ref. Is this how I would use it?
No. Basically, you want to use reform any time where you would
otherwise have to break the chain and call
L(that_sub($l->map(\&f1)))->map(\&f2);
Instead, you can
$l->map(\&f1)->reform(sub {that_sub(@_)})->map(\&f2);
> @a0 = qw(abel abel baker camera delta edward fargo golfer);
> $l = L(@a0);
> $reform = $l->reform( sub { return $_ } );
I hope the new docs help clarify that. I notice the tendency to put $_
in a reform sub, which is incorrect. These subs only see @_ (but IIRC,
$_ is not undef and therefore this caused me a silent error yesterday
when I made the same mistake (maybe I should localize $_ as undef?))
Is there a better name than reform? My intent was to use it when e.g .
you wanted to break a flat list into several nested array refs -- a
case where $_ per-element processing is not possible (you need to pass
the entire list and return an entirely new one.) Thus the name choice,
but maybe it should be something more explicitly in contrast to map
Just FYI, it looks a bit different than what the reform() function in Array::Reform does -
http://search.cpan.org/~kilinrax/Array-Reform-1.04/Reform.pm
the author of that module is not very responsive to bug reports, so maybe we could add in that reform() functionality and name this something else (no idea what)
