JuliaStats / Statistics.jl

The Statistics stdlib that ships with Julia.
https://juliastats.org/Statistics.jl/dev/
Other
71 stars 40 forks source link

`mean`'s dry run #124

Closed thevolatilebit closed 2 years ago

thevolatilebit commented 2 years ago

I used to assume that mean(f, itr) calls f once for each of the elements of itr.

However, there is an (extra) dry run which

In Slack's #helpdesk channel, it was also noted that there could be some issues with weirdly indexed arrays.

For example,

g3 = 0; mean(i -> (global g3 += 1; 1), 1:1)

results in g3 == 2.

Moreover, this behaviour is not documented.

fredrikekre commented 2 years ago

See #49