2.13. Go language functions as arguments

发布时间 :2023-10-12 23:00:10 UTC      

Go language has the flexibility to create functions and use them as arguments to another function. In the following example, we initialize a variable in a defined function just to use the built-in function math.sqrt() , an example is:

2.13.1. Example #

package main
import (
   "fmt"
   "math"
)
func main(){
   /* Declare function variables */
   getSquareRoot := func(x float64) float64 {
      return math.Sqrt(x)
   }
   /* Using functions */
   fmt.Println(getSquareRoot(9))
}

The result of the above code execution is:

3

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.