TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

McCarthy's amb operator in Python

2 pointsby coconutrandomover 13 years ago

1 comment

tmhedbergover 13 years ago
Isn't this essentially what list comprehensions are for? For instance, here's the Pythagorean triple example using a comprehension:<p><pre><code> [(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] </code></pre> 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.<p>Or am I missing something?
评论 #2942135 未加载