I have a very simple task, but for some reason I fail to accomplish it. I want to use Which
to define a function. I think the code is self-explanatory:
In: f[x_, y_] := Which[x == en, 1, y == en, 2]
In: f[en, a]
Out: 1
OK, so far so good. But if other condition is satisfied, nothing happens:
In: f[a, en]
Out: Which[a == en, 1, en == en, 2]
I would expect to get 2
as output, not this. Why is this so?
I got same result if I use numbers instead of the symbolic expressions, and same result if I use Piecewise
instead of Which
.
Any ideas? Thanks!