Extending piecwise to 2 variables (or a variable and a parameter)
This piecewise function work correctly
score = piecewise([([i,i], ncand - i) for i in range(ncand)])
because ncand is defined earlier in my notebook. when I typeset say score(1) It returns what I expect. But I would like that ncand be a variable.
scorecan only be evaluated in the integers $0, 1, 2,...,\mathtt{ncand}-1$ and, in fact, $\mathtt{score}(i)=\mathtt{ncand}-i$. Is it intended? Anyway, if you have something likeyou can redefine
scoreto depend onncandas follows:Juanjo it was intended
But you answer is not self evident. Even short it ananswer not a comment.
I have transformed my comment into an answer.