# New Ticket Created by  "Carl Mäsak" 
# Please include the string:  [perl #122475]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=122475 >


<timotimo> m: my @a = $(1, 2, 3); say [>>+<<] @a;
<camelia> rakudo-moar 3ad15f: OUTPUT«Not enough positional parameters
passed; got 1 but expected 2 [...]
<timotimo> m: my @a = $(1, 2, 3), $(0, 0, 0); say [>>+<<] @a;
<camelia> rakudo-moar 3ad15f: OUTPUT«1 2 3␤»
<timotimo> ^- i don't know how to formulate the bug report for this
<masak> "[BUG] instance of the reduce metaop which should work with
one-element list only works with two or more elements in Rakudo"
<timotimo> perfect
<timotimo> would you do the honors? :)
* masak submits rakudobug
<timotimo> thank you :)

I think I agree that this is a bug, with the following reasoning: [+]
accepts a list of zero, one, or many elements. The zero and one cases
are special-cased, to be sure, because addition usually involves two
things. But here it essentially means "sum", which can have any number
of things.

Similarly, [>>+<<] is also a kind of sum: in this case, it is summing
the internal structures of the items in the list (which have to be of
the same shape, because the >> << are pointing inwards). So the >> <<
restrict the shape of the items themselves, but not the number of
items. So this kind of sum of one item should work, and just return
that item.

In that vein, the 0-elem case should also work:

<masak> m: my @a; say [>>+<<] @a
<camelia> rakudo-moar 3ad15f: OUTPUT«Not enough positional parameters
passed; got 0 but expected 2 [...]

Reply via email to