package main
import (
"fmt"
"math"
)
func cappedPow(x, n, lim float64) float64 {
// executing a short statement before the
// actual condition occurs.
if v := math.Pow(x, n); v < lim {
return v
}
return lim
}
func main() {
fmt.Println(
cappedPow(3, 2, 10),
// also notice this damned trailing comma
// at the end of a "list"
cappedPow(3, 3, 20),
)
}
To embed this program on your website, copy the following code and paste it into your website's HTML: