NAME

Data::Frame::Autobox - Autobox arrays and hashes for Data::Frame

VERSION

version 0.0053

SYNOPSIS

    use Data::Frame::Autobox;

    [ 1 .. 5 ]->isempty;    # false

    { one => 1 }->names;    # [ 'one' ]
    { one => 1 }->isempty;  # false

DESCRIPTION

This package provides a set of methods for autoboxed arrays and hashes.

ARRAY METHODS

isempty

    my $isempty = $array->isempty;

Returns a boolean value for if the array ref is empty.

grep

    my $new_array = $array->grep($coderef);

map

    my $new_array = $array->map($coderef);

at

    my $value = $array->at($idx);

uniq

    my $uniq_array = $array->uniq;

set

    $array->set($idx, $value);

length

    my $length = $array->length;

elems

This is same as length.

flatten

    my @array = $array->flatten;

Explicitly returns an array.

slice

    my $slice = $array->slice($indices);

copy

Shallow copy.

repeat

    my $new_array = $array->repeat($n);

Repeat for $n times.

repeat_to_length

    my $new_array = $array->repeat_to_length($l);

Repeat to get the length of $l.

intersect

    my $new_array = $array->intersect($other)

union

    my $new_array = $array->union($other)

setdiff

    my $new_array = $array->setdiff($other)

HASH METHODS

isempty

    my $isempty = $hash->isempty;

Returns a boolean value for if the hash ref is empty.

delete

    $hash->delete($key);

merge

    my $merged_hash = $hash->merge($other);

hslice

    my $sliced_hash = $hash->hslice($keys);

slice

This is same as hslice.

at

    my $value = $hash->at($key);

set

    $hash->set($key, $value);

exists

    my $bool = $hash->exists($key);

keys

    my $keys = $hash->keys;

names

This is same as keys.

values

    my $values = $hash->values;

flatten

    my %hash = $hash->flatten;

Explicitly returns an array.

copy

Shallow copy.

rename

    rename($hashref_or_coderef)

It can take either,

  • A hashref of key mappings.

    If a keys does not exist in the mappings, it would not be renamed.

  • A coderef which transforms each key.

    my $new_href1 = $href->rename( { $from_key => $to_key, ... } );
    my $new_href2 = $href->rename( sub { $_[0] . 'foo' } );

SEE ALSO

autobox

AUTHORS

  • Zakariyya Mughal <zmughal@cpan.org>

  • Stephan Loyd <sloyd@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014, 2019 by Zakariyya Mughal, Stephan Loyd.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.