McCarthy's amb operator in Python
paddy3118.blogspot.com
paddy3118.blogspot.com
[(a, b, c) for a in range(1, 11) for b in range(1, 11) for c in range(1, 11) if a ** 2 + b ** 2 == c ** 2]
I understand that the semantics are slightly different, but I'd argue that the benefit of using a built-in, idiomatic Python construct instead of reinventing the wheel is pretty clear.Or am I missing something?
[edit]
More info here: http://c2.com/cgi/wiki?AmbInPython