List-Flat

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

        push @a, \@a;
        @b = flat_f(\@a);

    So don't do that. Use `flat()` or `flat_r()` instead.

    When it is fed non-infinite lists, this function seems to be about 
    twice as fast as `flat()`.

# CONFIGURATION AND ENVIRONMENT

The functions will normally use Ref::Util to determine whether an
element is an array reference or not, but if the environment variable
$PERL\_LIST\_FLAT\_NO\_REF\_UTIL is set to a true value, or the perl
variable List::Flat::NO\_REF\_UTIL is set to a true value before
importing it, it will use its internal pure-perl implementation.

# DEPENDENCIES

It has one optional dependency, [Ref::Util](https://metacpan.org/pod/Ref::Util). 
If it is not present, a pure perl implementation is used instead.

# SEE ALSO

There are several other modules on CPAN that do similar things.

- Array::DeepUtils

    I have not tested this code, but it appears that its collapse()
    routine does not handle circular references.  Also, it must be

lib/List/Flat.pm  view on Meta::CPAN


our $VERSION = "0.003";
$VERSION = eval $VERSION;

use Exporter 5.57 'import';
our @EXPORT_OK = qw/flat flat_r flat_f/;

# if PERL_LIST_FLAT_NO_REF_UTIL environment variable is set to a true
# value, or $List::Flat::NO_REF_UTIL is set to a true value,
# uses the pure-perl version of is_plain_arrayref.
# Otherwise, uses Ref::Util if it can be successfully loaded.

BEGIN {
    my $impl = $ENV{PERL_LIST_FLAT_NO_REF_UTIL}
      || our $NO_REF_UTIL;

    if ( !$impl && eval { require Ref::Util; 1 } ) {
        Ref::Util->import('is_plain_arrayref');
    }
    else {
        *is_plain_arrayref = sub { ref( $_[0] ) eq 'ARRAY' };
    }
}

{
    my $croak;

    sub flat {

lib/List/Flat.pm  view on Meta::CPAN


So don't do that. Use C<flat()> or C<flat_r()> instead.

When it is fed non-infinite lists, this function seems to be about 
twice as fast as C<flat()>.

=back

=head1 CONFIGURATION AND ENVIRONMENT

The functions will normally use Ref::Util to determine whether an
element is an array reference or not, but if the environment variable
$PERL_LIST_FLAT_NO_REF_UTIL is set to a true value, or the perl
variable List::Flat::NO_REF_UTIL is set to a true value before
importing it, it will use its internal pure-perl implementation.

=head1 DEPENDENCIES

It has one optional dependency, L<Ref::Util|Ref::Util>. 
If it is not present, a pure perl implementation is used instead.

=head1 SEE ALSO

There are several other modules on CPAN that do similar things.

=over

=item Array::DeepUtils

t/withrefutil.t  view on Meta::CPAN

use strict;
use Test::More 0.98;
use List::Flat(qw/flat flat_f flat_r/);

note('Use Ref::Util for checking array references');

unless ( eval { require Ref::Util; 1 } ) {
    plan skip_all => 'No Ref::Util';
}

require './t/lib/list_flat.pl';

done_testing;



( run in 1.671 second using v1.01-cache-2.11-cpan-4d50c553e7e )