| 1 | initial version |
Define score as follows:
def score(x, ncand=10):
s = piecewise([([i,i], ncand - i) for i in range(ncand)])
return s(x)
Then you can use score as in the following examples:
sage: score(7)
3
sage: score(3, ncand=7)
4
sage: score(3,7)
4
Observe that, if omitted, the value of ncand is 10.
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.