摘要:
A Tour of Go系列。如有问题欢迎指出~这个也没什么好说的,就是试一下内建的复数运算。Let's explore Go's built-in support for complex numbers via thecomplex64andcomplex128types. For cube roots, Newton's method amounts to repeating:Find the cube root of 2, just to make sure the algorithm works. There is aPowfunction in themath 阅读全文
posted @ 2012-10-11 22:27
Gizak
阅读(267)
评论(0)
推荐(0)
摘要:
A Tour of Go系列。如有问题欢迎指出~closure即是俗话说的闭包,闭包三言两语说不清楚,而且本人也不甚了解。简单说就是语法定界,内部的函数可以引用外部上下文的变量,外部的变量会随之捕获并保存。一般来说带闭包的语言函数是可以作为first class的,Go也是如此。这意味这在Go中你可以以类似普通变量一样声明、赋值、传递一个函数变量。练习要求:Implement afibonaccifunction that returns a function (a closure) that returns successive fibonacci numbers.实现一个斐波那契数列函数, 阅读全文
posted @ 2012-10-11 21:43
Gizak
阅读(321)
评论(0)
推荐(0)
摘要:
A Tour of Go系列。如有问题欢迎指出~第三篇,先解释一下要求:ImplementPic. It should return a slice of lengthdy, each element of which is a slice ofdx8-bit unsigned integers. When you run the program, it will display your picture, interpreting the integers as grayscale (well, bluescale) values.The choice of image is up to y 阅读全文
posted @ 2012-10-11 20:22
Gizak
阅读(768)
评论(0)
推荐(1)

浙公网安备 33010602011771号