RosettaCodeData/Task/Function-composition/Go/function-composition-1.go

12 lines
360 B
Go
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
// Go doesn't have generics, but sometimes a type definition helps
// readability and maintainability. This example is written to
// the following function type, which uses float64.
type ffType func(float64) float64
// compose function requested by task
func compose(f, g ffType) ffType {
return func(x float64) float64 {
return f(g(x))
}
}