Hi Mark,

Try this:

my @dice =
(
    # type        pips on first die   pips on second die  tally
    ('normal',    (1, 2, 3, 4, 5, 6), (1, 2, 3, 4, 5, 6), (0 xx 14).Array),
    ('Sicherman', (1, 3, 4, 5, 6, 8), (1, 2, 2, 3, 3, 4), (0 xx 14).Array)
);

The problem in your code is that 0 xx 14 is a List, not an Array. Lists are
immutable, while Arrays use a container, so are rw.

As the doc says (https://docs.perl6.org/type/List):

"You can assign to list elements if they are containers. Use Arrays to have
every value of the list stored in a container."

On Wed, Dec 13, 2017 at 4:41 AM, Mark Senn <m...@purdue.edu> wrote:

> # I define
> my @dice =
> (
>     # type        pips on first die   pips on second die  tally
>     ('normal',    (1, 2, 3, 4, 5, 6), (1, 2, 3, 4, 5, 6), 0 xx 14),
>     ('Sicherman', (1, 3, 4, 5, 6, 8), (1, 2, 2, 3, 3, 4), 0 xx 14)
> );
> # and later do
> @dice[1;3;2]++;
> # and get
> #     Cannot resolve caller postfix:<++>(Int); the following candidates
> #     match the type but require mutable arguments:
> #         (Mu:D $a is rw)
> #         (Int:D $a is rw)
> #
> #     The following do not match for other reasons:
> #         (Bool:D $a is rw)
> #         (Bool:U $a is rw --> Bool::False)
> #         (Mu:U $a is rw)
> #         (Num:D $a is rw)
> #         (Num:U $a is rw)
> #         (int $a is rw)
> #         (num $a is rw --> num)
> #       in block <unit> at ./t.p6 line 13
> #
> # I want to keep the array structure for the data.
> # What's the cleanest solution.  Thanks.    -mark
>



-- 
Fernando Santagata

Reply via email to