The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

FP::MutableArray

SYNOPSIS

    use FP::MutableArray;
    use FP::Div 'inc';

    my $a= mutablearray(1,4,5)->map(*inc);
    is $a->sum, 13;
    $a->[0]++;
    is $a->sum, 14;

    # They can be turned into immutable ones:
    my $b= $a->pure;
    like( (eval { $b->[0]++; 1 } || $@), qr/XXX Hello?/);
     # XXX sigh, expecting 'Modification of a read-only value attempted', but
     # Test::More never fails here ???

    # Although this really consumes the original array, which is now
    # immutable, too:
    like( (eval { $a->[0]++; 1 } || $@), qr/WHATXXX/);

    is $a->sum, 14;

    is( FP::_::MutableArray->null == FP::_::MutableArray->null, '' );

DESCRIPTION

Native Perl arrays but blessed so that they can follow the sequences protocol.

SEE ALSO

Implements: FP::Abstract::Sequence.

FP::PureArray, FP::Array

NOTE

This is alpha software! Read the package README.