Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "math"
- )
- func pow(x, n, lim float64) float64 {
- if v := math.Pow(x, n); v < lim {
- return v
- } else {
- // v still defined.
- fmt. Printf("%g >= %g\n", v, lim)
- // return v
- }
- // v no longer defined.
- // unless specified in "else" block, must be specified here. Will only be invoked when "if" is not true.
- return lim
- }
- func main() {
- var pow_vals = [][]float64{
- {3, 2, 10},
- {3, 3, 10},
- }
- for _, powval := range pow_vals {
- fmt.Println( pow(powval[0], powval[1], powval[2]) )
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement