Message313984
Ah wait, I appear to have misunderstood Raymond's request. Sorry Raymond!
(I've been spending too much time teaching Pythagoras' theorem and my mind was primed to go directly from Euclidean distance to hypotenuse.)
Not withstanding my misunderstanding, if hypot supported arbitrary number of arguments, then the implementation of distance could simply defer to hypot:
def distance(p, q):
# TODO error checking that p and q have the same number of items
return hypot(*(x-y for x,y in zip(p, q)))
giving results like this:
py> distance((11, 21), (14, 17))
5.0
In either case, I agree with Raymond that this would be a useful feature. |
|
Date |
User |
Action |
Args |
2018-03-17 00:36:38 | steven.daprano | set | recipients:
+ steven.daprano, tim.peters, rhettinger, mark.dickinson, skrah |
2018-03-17 00:36:38 | steven.daprano | set | messageid: <1521246998.03.0.467229070634.issue33089@psf.upfronthosting.co.za> |
2018-03-17 00:36:38 | steven.daprano | link | issue33089 messages |
2018-03-17 00:36:37 | steven.daprano | create | |
|