[Python-ideas] Function composition (was no subject)
Koos Zevenhoven
koos.zevenhoven at aalto.fi
Sat May 9 06:00:52 CEST 2015
On 9.5.2015 5:58, Stephen J. Turnbull wrote:
> Koos Zevenhoven writes:
>
> > As a random example, (root @ mean @ square)(x) would produce the right
> > order for rms when using [2].
>
> Hardly interesting. :-) The result is an exception, as root and square
> are conceptually scalar-to-scalar, while mean is sequence-to-scalar.
>
> I suppose you could write (root @ mean @ (map square)) (xs), which
> seems to support your argument. But will all such issues and
> solutions give the same support? This kind of thing is a conceptual
> problem that has to be discussed pretty thoroughly (presumably based
> on experience with implementations) before discussion of order can be
> conclusive.
>
Well, you're wrong :-)
Working code:
from numpy import sqrt, mean, square
rms = sqrt(mean(square(x)))
The point is that people have previously described sqrt(mean(square(x)))
as root-mean-squared x, not squared-mean-root x. But yes, as I said,
it's just one example.
-- Koos
More information about the Python-ideas
mailing list