A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2001-January/011965.html below:

[Python-Dev] Rich comparison confusion

[Python-Dev] Rich comparison confusionTim Peters tim.one@home.com
Sun, 21 Jan 2001 20:23:27 -0500
[Michael Hudson]
> ...
> if you meant min(a,b), then I then think the programmer who
> thinks "min(a,b)" is spelt "a<b" has problems we can't be expected to
> deal with (if min has a symbol it's /\, but never mind that).

Curiously, in the Icon language, if a is less than b then

   a < b

returns b while

   b > a

returns a.

In this way they get the same effect as Python's chained comparisons

   a < b < c < d

via purely binary operators (if a is *not* less than b, a < b in Icon
"fails", which is a silent event that causes the expression's context to
backtrack -- but we won't go into that here <wink>).

Anyway, that accounts for this curious Icon idiom:

   a <:= b

which is short for

   a := a < b

and binds a to max(a, b) (if a is smaller, a < b returns b and the
assignment proceeds; but if a is not smaller, a < b fails and that
propagates into its context, which here has no other possibilities to
backtrack into, so the stmt just ends leaving a alone).

"<"-and-">"-are-just-bags-of-pixels-ly y'rs  - tim




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