Re: [Rd] Recycling in arithmetic operations involving zero-length vectors

2023-01-17 Thread peter dalgaard
Actually, sum(), all(), any(), prod() all return a _carefully considered_ result in the case of an empty vector. The sum over a disjoint union of sets should be the sum of the sums over each set, so if a set is empty, its contribution to the sum must be zero. Similarly, the product over an

Re: [Rd] Recycling in arithmetic operations involving zero-length vectors

2023-01-16 Thread GILLIBERT, Andre
Duncan Murdoch wrote: > To even do that, we would have to first decide which "cases" should produce a > warning. > Let's say `1 + x` should give a warning when x = numeric(0). Then should > `x^2` also produce a warning? Should `x^0.5`? Should `sqrt(x)`? > Should `log(x)`? The most probable

Re: [Rd] Recycling in arithmetic operations involving zero-length vectors

2023-01-16 Thread Deepayan Sarkar
On Mon, Jan 16, 2023 at 7:28 PM Duncan Murdoch wrote: > > On 16/01/2023 6:55 a.m., David Winsemius wrote: > > > > > > Sent from my iPhone > > > >> On Jan 16, 2023, at 6:11 PM, Duncan Murdoch > >> wrote: > >> > >> On 16/01/2023 5:23 a.m., Roland Fuß wrote: > >>> Dear R-core, > >>> The language

Re: [Rd] Recycling in arithmetic operations involving zero-length vectors

2023-01-16 Thread Duncan Murdoch
On 16/01/2023 6:55 a.m., David Winsemius wrote: Sent from my iPhone On Jan 16, 2023, at 6:11 PM, Duncan Murdoch wrote: On 16/01/2023 5:23 a.m., Roland Fuß wrote: Dear R-core, The language definition is very clear: "As from R 1.4.0, any arithmetic operation involving a zero-length vector

Re: [Rd] Recycling in arithmetic operations involving zero-length vectors

2023-01-16 Thread David Winsemius
Sent from my iPhone > On Jan 16, 2023, at 6:11 PM, Duncan Murdoch wrote: > > On 16/01/2023 5:23 a.m., Roland Fuß wrote: >> Dear R-core, >> The language definition is very clear: >> "As from R 1.4.0, any arithmetic operation involving a zero-length >> vector has a zero-length result." >>

Re: [Rd] Recycling in arithmetic operations involving zero-length vectors

2023-01-16 Thread Duncan Murdoch
On 16/01/2023 5:23 a.m., Roland Fuß wrote: Dear R-core, The language definition is very clear: "As from R 1.4.0, any arithmetic operation involving a zero-length vector has a zero-length result." Thus, `1 + numeric()` returns `numeric(0)`. However, I don't find this very intuitive because