A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/328595.html below:

C#3.0 and lambdas

C#3.0 and lambdasScott David Daniels Scott.Daniels at Acm.Org
Wed Sep 21 12:02:18 EDT 2005
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)

--Scott David Daniels
Scott.Daniels at Acm.Org

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4