package main import ( "fmt" ) func main() { multiply := func(values []int, multiplier int) []int { multipliedValues := make([]int, len(values)) for i, v := range values { multipliedValues[i] = v * multiplier } return multipliedValues } add := func(values []int, additive int) []int { addedValues := make([]int, len(values)) for i, v := range values { addedValues[i] = v + additive } return addedValues } ints := []int{1, 2, 3, 4} for _, v := range add(multiply(ints, 2), 1) { fmt.Println(v) } fmt.Println("") for _, v := range multiply(add(multiply(ints, 2), 1), 2) { fmt.Println(v) } }
image.png
以上所述就是小编给大家介绍的《Golang简单的pipline》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Numerical Recipes 3rd Edition
William H. Press、Saul A. Teukolsky、William T. Vetterling、Brian P. Flannery / Cambridge University Press / 2007-9-6 / GBP 64.99
Do you want easy access to the latest methods in scientific computing? This greatly expanded third edition of Numerical Recipes has it, with wider coverage than ever before, many new, expanded and upd......一起来看看 《Numerical Recipes 3rd Edition》 这本书的介绍吧!