913 B
913 B
| id | name | category | kind | tokens | sig | tip | order | ns | member |
|---|---|---|---|---|---|---|---|---|---|
| math-min | Math.min | math | namespace-method | Math.min | Math.min(a, b) -> int | The smaller of two values. | 0 | Math | min |
Returns whichever of a and b is smaller. It works on plain int values and on fixed values alike — both are stored as signed 32-bit words, so the comparison keeps their order either way. Use it to cap a value at a ceiling, keep a cursor inside a list, or take the nearer of two distances. The bare form min(a, b) is kept as a convenience alias.
Parameters:
a— the first valueb— the second value
program ClampScore {
state ClampScoreState {
score: int = 0
}
handler AddPoint(clamp_score_st: mut ClampScoreState) phase Update {
clamp_score_st.score = Math.min(clamp_score_st.score + 1, 100) # never climbs past 100
}
}