C#3.0 and lambdas
Bill Mill
bill.mill at gmail.com
Wed Sep 21 13:02:22 EDT 2005
On 9/21/05, Scott David Daniels <Scott.Daniels at acm.org> wrote:
> Roel Schroeven wrote:
> > ...
> > Christophe schreef:
> >> ...
> >>And what about a function which computes the line length ?
> >
> > That would have been a better example indeed, since the *p1 trick
> > doesn't work there.
> >
> > def euclidian_distance((x1, y1), (x2, y2)):
> > return math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
> >
> > That's a lot nicer, I think, than this:
> >
> > def euclidian_distance(p1, p2):
> > return math.sqrt((p2[0] - p1[0])**2 + (p2[1] - p1[1])**2)
>
> But not massively nicer than:
>
> def euclidian_distance(p1, p2):
> (x1, y1), (x2, y2) = p1, p2
> return math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
>
But the question is - why go to the effort to remove the (by your
admission) slightly nicer version?
Peace
Bill Mill
bill.mill at gmail.com
More information about the Python-list
mailing list