
Carl Johnson schrieb:
Andrey Popp wrote:
I am not about list comprehension only, there are other cases for where-clause, for example lambdas:
f = lambda x: (x, y) if x > 0 else (x, 0) where y = g(x)
Yuck. This reminds me of why I gave up on the Haskell tutorial I was working through. The reading of this line keeps bouncing back and forth. "OK, function f, passing in x, returning x, y… Wait? What's y? Is that from an external scope? Anyway, here's an if-else clause, and oh, there's the y! It's the same as g(x). OK, so where all did they use y? Hmm, lets see, looks like just the one spot…"
I know what you mean :) I think "where" is best used where you all but know exactly what the where-bound name refers to, but have to spell it out for the stupid computer somewhere... Georg